|
I would like to know how to lock an axis to keep an object from rotating on it. I am using JavaScript and I need the Z axis to be locked, due to the Z axis's value changing during the rotation of the X and Y axis's due to joystick I am new to Unity3D and scripting altogether but so far this is the only trouble i have came across. Thanks in advanced; Dylan Wright
(comments are locked)
|
|
You might have a look at either of these answers: i couldn't get anything out of them i tried some of the codes but my object still rotated on the Z axis some when i moved the joystick up adjusting the Y axis. If it helps i'm looking for something like the MouseLook Script but i can't use it on this object because I've used it on another object and it produces errors when used on two objects.
Mar 20 '10 at 03:19 PM
user-1559 (google)
(comments are locked)
|
|
Take a look at this answer: http://answers.unity3d.com/questions/4011/how-do-i-lock-out-a-axis i checked that out but it says thats for position but i tried to change "position" to "rotation" and it didn't work for some reason, it looked like it would, here is my script : var speed = 3.0; var rotateSpeed = 3.0; function Update () { }
Mar 20 '10 at 01:48 PM
user-1559 (google)
You are using '0' as 3rd parameter of the Rotate function. This is equal to Space.World. The default would be Space.Self and that should work for you. Space.World let's your object rotate around (0,1,0) regardless of your object's local y-axis. You should always use the built-in enums instead of ints. This helps clarifying your code a lot.
Mar 21 '10 at 05:58 PM
StephanK
(comments are locked)
|
|
I fixed it, for some reason when i duplicated the MouseLook Script before i must have left out something, if using the MouseLook script to control two different options with two different inputs just change this :
to something like this :
and it will work just fine. It did for me anyways. Thanks for the help though i figured it out on my own.
(comments are locked)
|
