|
I'm attempting to adjust the barrel of a gun up and down (to show it's going fire a further distance) I can get it to rotate just fine, but i only want it to rotate with in a certain radius otherwise you can just keep flipping it. this doesn't seem to work. I thought maybe the rotation would be in radians (that broke things) so i believe my math is messed up.. so this is what i want to do, have a gun that moves down when you press S and if it goes to 350 (after wrapping past 0,) it stops.. on the other side, i would like to do the opposite with W where if it goes from 350 (wrapping past 0) to 20 it stops at 20.
(comments are locked)
|
|
i've changed how i am checking my code, i'm not using a second rotation to set it, cause it's not catching it, i also threw in some variables to check for wrapping. I also built in a boolean catch to try and stop it, some time it works some times i can get past it, some times it doesn't catch it at all... this is my full update code for it. still could use some help on this, i'm not sure if i should use the second vector as i never caught anything with trying it. thanks!
(comments are locked)
|
|
The default rotation vector is interpreted as a quaternion, which is better for the maths but really hard to visualize. Try localEulerAngles instead, which is the XYZ rotation relative to the parent object: You may also need to handle wrapping if the Z exceeds 360 or drops below 0, because it won't do it for you. this kind of works, but it never stops spinning and the second i let go of s or W it just keeps spinning.
Jan 04 '12 at 02:07 AM
kievar1983
(comments are locked)
|
