Transform position and rotation issue


#1

Hey guys,
programming with Xenko 2.0 I found issues relative to the update of the axis.
Rotating an Entity, axis should rotate with it right? This not happen when i use this code:
* Entity.Transform.Rotation = Quaternion.RotationAxis(c, angle);

  •     _Entity.Transform.Position += new Vector3(0,0,-0.01f);_
    

Anyone knows how fix this problem?
Thanks in advance :dancer:


#2

If I remember correctly, Transform.Position is a vector3 in World Space. Thus, even if you rotate the Entity, moving it along an axis will always be the same.

You would need to rotate the vector first by the rotation of the object to get it in relative space.

Eg: Entity.Transform.Position += Entity.Transform.Rotation * new Vector3(0,0,1f);

(iā€™m not sure anymore if the quaternion needs to be first of second to rotate a vector. Those are not permutable, but it should work. This is from the top of my head. :stuck_out_tongue: )