Quantcast
Channel: Latest Questions by AmasterAmaster
Viewing all articles
Browse latest Browse all 57

How to align an object's rotation to another GameObject's rotation (without parenting the Objects)

$
0
0
If this question has been answered before, please let me know, as I do not know how to properly word this problem. But I will give it a try. What I want to do is to align the rotation of a gameobject by reading in the rotation data of another gameobject. The reason for this is to make a mini-map type of camera that has a bird's eye view of the player's position, but parenting would make the camera display very awkward (especially with an orthographic view) due to the player also leaning forward/backward and left/right. So I settled for an idea of a rotation solution where I would need to set the object's rotation in a way to rotate with the player, but I ran into problems when trying different rotation and quaternion functions. Here are the things I have tried so far: //myTransform.rotation = new Quaternion(transformToAlignTo.rotation.x, myTransform.rotation.y, myTransform.rotation.z, myTransform.rotation.w); //myTransform.localEulerAngles = new Vector3(transformToAlignTo.rotation.x, myTransform.localEulerAngles.y, myTransform.localEulerAngles.z); //myTransform.rotation = Quaternion.FromToRotation(Vector3.up * debugSpeed, transform.forward * debugSpeed); //myTransform.rotation = Quaternion.FromToRotation(Vector3.up * debugSpeed, transform.forward * debugSpeed); //myTransform.Rotate(Vector3.right, debugSpeed * Time.deltaTime); //myTransform.Rotate(Vector3.right, transformToAlignTo.rotation.x); //myTransform.Rotate(0, transformToAlignTo.rotation.y, 0); //myTransform.rotation = Quaternion.LookRotation(transformToAlignTo.position); //myTransform.rotation = Quaternion.LookRotation(new Vector3(0, 1, 0)); //Vector3 v = myTransform.position - Vector3.up; //myTransform.rotation = Quaternion.FromToRotation(transform.up, v); //myTransform.LookAt(transformToAlignTo.position, Vector3.forward); So my question is, how can I make the bird's eye view mini-map camera object become aligned with the player object rotation? (As in, When a player turns left or right, the mini-map camera also rotates with up being always the player's forward, if that makes any sense) Any and all help is appreciated.

Viewing all articles
Browse latest Browse all 57

Latest Images

Trending Articles





Latest Images