this is what I am using to update the rotation
Vector3 lookAtPoint = new Vector3( x, y, z );Vector3 myPosition = this.transform.position;lookAtPoint -= myPosition;float r = Mathf.Sqrt( lookAtPoint.x*lookAtPoint.x + lookAtPoint.z*lookAtPoint.z );float yaw = Mathf.Atan2(lookAtPoint.x, lookAtPoint.z);float pitch = Mathf.Atan2(lookAtPoint.y * -1.0f, r);//yaw and pitch are converted with Mathf.Rad2Deg
There is nothing special that i need in my implementation, so far i do not need to take account velocities and acceleration.
For now i really just need to rotate the missile towards the target and then move the missile towards its z axis.
I already have this implemented for a normal missile that just goes forward, now this one I want to follow the target.
I have a math library to help me with quaternions and matrices if need (Sharp3D.Math), but i dont know for example how to get a forward vector our of a matrix or out of a quaternion.
The non-guided missile NPC that I have now, can only move forward because when I shoot it I get the forward vector of the ship that just shot it, and store it on the server npc object.
So this guided missile npc that I want to implement would be a variation of the missile npc that I already have, only that it has to change its forward vector once it changes the rotation so it can go straight but in the new forward vector direction right?
Does it sound like it would work? If there is another better approach to this please let me know, the reason I want to keep using the forward vector is that its already implemented in the npc class and I just want to extend it.