- Home /
Rotate y axis of parent GameObject toward center of camera view with focus on a Child GameObject
I'm trying to rotate a GameObject cube primitive flattened to act as a ground. I then have multiple building GameObjects as child objects of the ground object. Assuming user 'clicks' on a building to the far back, I want to rotate the ground GameObject around to the clicked building. Placing the building in front of a stationary camera.
I have the rotation working. Now I just need to figure out how to rotate the ground around to have the camera focus on the child GameObject building that's been clicked.
Any help would be greatly appreciated.
The code below works to rotate the floor.
/*
* Button functionality to rotate inverse left.
*
*/
public void RotateLeft()
{
discTerrain.transform.Rotate (Vector3.up, -turnSpeed * Time.deltaTime);
}
/*
* Button functionality to rotate inverse right.
*
*/
public void RotateRight()
{
discTerrain.transform.Rotate (Vector3.up, turnSpeed * Time.deltaTime);
}
Your answer
Follow this Question
Related Questions
Animation rotations are not rotating in the right direction. 1 Answer
Just updated to 2017.3.0f3 And my moving platforms are locking my character's rotation 1 Answer
How can i rotate a object more than once (90 degrees)? 1 Answer
Flip over an object (smooth transition) 3 Answers
Does modifying a parent gameobject's rotation affect the child gameobject's position? 2 Answers