- Home /
How do I rotate planes around a cube?
Okay so I have 3 planes facing the camera. I want these to rotate around the cube that is in the center of all 3 of these cubes. I have tried parenting the planes to the cube and then I put this script for the cube
function Update ()
{
transform.Rotate(Input.acceleration.x,-Input.acceleration.y , 0 );
transform.Translate(2,0,0);
}
But It endlessly rotates. I want it to be on every left click it rotates 120 degrees. Thanks in advance!
~Connor
Answer by Screenhog · Jul 17, 2012 at 08:09 PM
Well, to do something on a click, one good way to do it is:
if (Input.GetMouseButtonUp(0)) {
//put code in here
}
Right now, you have it happening within an Update() function, which means it will happen every frame.
What I would do is have the three planes as children of the cube, placed where you want them to be in relation to the cube. Add this code within an Update function:
if (Input.GetMouseButtonUp(0)) {
Transform.Rotate(0, 0, 120);
}
You'll probably also want a LookAt function on the planes themselves, so that they're always looking at the camera.
I think he is using a mobile device. Input.touchCount is more likely to do it.
Your answer
Follow this Question
Related Questions
How do you flip a card with smooth rotation? 1 Answer
Rotate an Object 1 Answer
How to rotate a 2D object on touch 1 Answer
Character to Ground and Turn Rotation 1 Answer
Return Camera Rotation Z axis to 0 2 Answers