Talked about it many times. And not sure if it's possible.

I need a example script, that rotate the entity. So the X direction is changing. When i then do a position move when incrementing the X that the entity is moving in the X direction it's pointing to.

Still hope sansar get soon some command for it that is doing this in easy way. Unless it can be done with current scripting already. But without a woring example i think it's a did black spot to understand.

• OldVamp

so you moved an object from start point to end point and you want it to be looking in the direction of end point?

if you subtract start from end, that will give you a direction of travel

Vector start = new Vector(2f, 2f, 0f);
Vector end =newVector(6f, 6f, 0f);
entity.SetPosition(end);
Vector travel = end - start;
// <6,6,0> - <2,2,0> = <4,4,0>
Quaternion neworientation = Quaternion.FromLook(travel,Vector.Up);
entity.SetOrientation(neworientation);

how an object was exported may affect its final orientation so you may have to rotate the neworientation if it is off.

Quaternion rot90 = Quaternion.FromEulerAngles(new Vector(0,0,Mathf.RadiansPerDegree * -90,0));

neworientation = neworientation * rot90;

Edited by OldVamp
• Richardus Raymaker

Hmm. <thinking>. It's so hard to explain.

I increaste the X position of the entity. always increasing only X in this example. the entity is looking into the X direction. Now i go rotate it so the X direction change on the entity. Now the movement need to change automatic. So it still keeps moving into the direction it points on the X side. It's a bit what liniearvolocity and rotate is doing. But then you want todo the with SetPosition instead.

I need to try the above example. but not sure if that is doing what i mean. because the dirction wil, alwasy only be <1,0,0> and that you increment while moving. When you rotate the prim you still increment only The X. But pretty sure the prim is not moving by local X. but world X.

• OldVamp

ok, you want to rotate an object then have it move in the direction it is facing.

similar solution

Vector Center = RigidBodyObject.GetPosition();
Quaternion objectorient = RigidBodyObject.GetOrientation();
offset = offset.Rotate(ref objectorient);
Vector newpos = Center + offset;
RigidBodyObject.SetPosition(newpos);
Edited by OldVamp
• Richardus Raymaker

Thanks, I go play a bit with that soon.

• Richardus Raymaker

To explain what i want at soem point in SanSar. For now i try todo it again in opensim. I need to test a few new idea's. That i can use later i hope in sansar.

The train in the video below. the front is always X+. When the train follow the track. The X direction rotate with the train. So you only need to rotate and increment the X value in the position field.