- Home /
Rotate Issue
I'm instantiating a game object and want to move and rotate it according to the player. If I only set the rotations equal to each other it works, however I need to rotate the z axis an additional 90 degrees which is causing some problems.
playerVector = new Vector3(transform.position.x,0.0675f, transform.position.z);
ghostMovement.transform.position = (transform.forward * 4f) + playerVector;
ghostMovement.rotation = transform.rotation;
However I need to change the z rotation, and thought I'd be able to just add this after what I previously had:
ghostMovement.rotation.z += 90;
This didn't work and gave me error stating I needed to store the value in a temporary variable which I did with no luck. After googling around I found the Quaternion.Euler and transform.Rotate.
ghostMovement.rotation = Quaternion.Euler(0f,transform.rotation.y,90f);
ghostMovement.transform.rotation = ghostMovement.transform.Rotate(0f,transform.rotation.y,90);
The Euler method worked (sort of) but didn't update the y position. While the Rotate method gave me an error: "Cannot implicitly convert type void to UnityEngine.Quaternion". This code is within the Update() function but unsure how to fix that.
Any help would be great.