I have a game where you are in a sub-sea environment, and fly about in a ship.
Im controling the ship via an xbox 360 controller, using this..
And i have the other analogue stick controlled by the 'mouse look' standard script attached to the object. As well as the triggers on the back for climbing and decending.
It all looks fairly well so far, but im stuck with how to get the object to tilt when it slides side to side using my 'horizontalSpeed' axis.
i have tried adding
to it, and other variations, but nothing seems to make it rotate.
Is there some easier way of doing this? - or have i just failed to understand something.
Could the mouse look be canceling out my rotation values?
Any advice would be appreciated, thanks!
I think you're right, and in your case the mouse look script is canceling your rotation. To start I would try and disable the mouse look scripts and try and make the tilting work.
After that look in the mouse look script and see where it updates transform.rotation or transform.localRotation.
I have a MouseLook script here, but I'm not sure it's the original one. Anyway, there should be a line similar to
Each frame the local rotation is reset to the value set here, so if your script happens to run before the mouse look script - you won't see the tilt. Script run order is pretty random unless you make some steps to sync them.
Try and adding your tilt right after this line.
I would even edit this line. Maybe add a zQuaternion that will hold the tilt rotation. Just remember that in that case - you can't really use transform.Rotate since it's a method that rotates the object X degrees EACH FRAME. I would create the necessary quaternion just like the xQuaternion and the yQuaternion are created.
answered Apr 26 '11 at 09:08 AM