- Home /
Rotation that keeps upright
Hello, I am currently programming a fairground ride and I want the seats where people sit to have a target rotation of being upright but I want it to transition to this rotation. The Axis I want it to rotate on the x axis. I do not really know if someone could help me. Here is an image to explain what I am looking for: http://prntscr.com/ctvo0q
As you can see, I want this to rotate on the ride. If you want to look what the ride IRL is like, its called danter's air.
Thanks.
Answer by b1gry4n · Oct 15, 2016 at 02:20 AM
Make the chairs children objects of the arm and rotate them locally.
chair.transform.localRotation = Quaternion.Euler(new Vector3(chair.transform.localEulerAngles.x + (Time.deltaTime * speed), 0, 0));
your ride hierarchy would be : base > long horizontal arm > spinning hand > rotating chairs
each would be rotating in local space using similar code to the above example.
You could skip all this and make an animation. That would probably be even easier/more control/better performance. Your code would be starting/stopping the animation
https://unity3d.com/learn/tutorials/topics/animation/animation-view?playlist=17099
Something like this, i would skip mecanim and use legacy.
The code does not work!! Please help! I would rather try the code first before animating.
It just makes it the same angle as the spinning bit so when its upside down, it stays that way but I want it to be facing directly upwards.