In a SystemBase.ForEach, how do I “LookAt” a point?(aka rotate such that my game object faces this point.)
I found clues here: How do you set non-local rotation in ECS? (also: documentation feedback)
- my code:
Entities
.WithName(“RotationSpeedSystem_ForEach”)
.ForEach((ref Rotation rotation, ref Translation translation, ref LocalToWorld ltw, ref MovementDataEntity movementData, ref DroneDataEntity dd, ref PhysicsVelocity pv) =>
{
//TRYING for Entity to look at me. My location: 5,20,54
UnityEngine.Vector3 newDir = UnityEngine.Vector3.RotateTowards(ltw.Forward, new UnityEngine.Vector3(5, 20, 54), 13f, 0f);
rotation.Value = quaternion.EulerXYZ(newDir.x, newDir.y, newDir.z);
- my picture result: https://crystalfighter.com/code/16.png*