- Home /
Need help to modify Space.World rotation script.
Hi,this script rotates object on world cordinates (around its axis) so what i want to do is,when i press "button" then it only rotates 180 degrees,not all the time,only 180 degrees and when i press again "button" it rotates back to its position. please help me :)
function Update() {
transform.Rotate(Vector3.left , Space.World);
}
Answer by diegzumillo · Nov 22, 2013 at 09:21 PM
Do you want it to be instantaneous or continuously moving? Either way there is a number of ways to do it. Instantaneous you can do simply like this:
if(Input.GetButtonDown("Jump")){
transform.Rotate(Vector3(90,0,0));
}
If you want to make a continuous movement it will depend on what kind of movement you want.
edit: of course, "jump" and "vector3(90,0,0)" are just illustrative values. Use whatever you want.
Your answer
Follow this Question
Related Questions
Need help to modify rotation script. (Quaternion) 1 Answer
[HELP] Rotate Bullet Script 0 Answers
Z rotation locks to certain value randomly? 0 Answers
Object won't rotate z axis on second click? 2 Answers
Transform.LookAt and Back! 1 Answer