Hi,
I am trying to rotate and entity but it shows weird numbers on the LocalToWorld component. This is the code:
var rot = new Rotation { Value = new quaternion(90, 0, 0, 1) };
entityManager.SetComponentData(CurrentEntity, rot);
How can I change rotation without changing any scale on the LocalToWorld component?
Greets and thanks
Quaternions don’t work like euler angles. The easiest way to apply euler angle rotations to an entity is to add one of the RotationEuler components to the entity and edit that component.
Thanks! I forget quaterion is really different from eular.
I got it working with quaterion, is this an good approach for it? Im turning an entity 90 degrees
Quaternion oldRotation = entityManager.GetComponentData<Rotation>(CurrentEntity).Value;
var newRotation = new Rotation { Value = Quaternion.Euler(0, oldRotation.eulerAngles.y + 90, 0)};
entityManager.AddComponentData(CurrentEntity, newRotation);
If an entity has one of the 6 RotationEuler components and a Rotation component, the EndFrameRotationEulerSystem will handle it for you.