- Home /
Roll based on turning speed
I'm working on a Space based top down RTS and I'm using bits of the SmoothLookAt script to make the ships rotate smoothly to 'look at' the point that was right clicked (everything's y position always = 0) - this works great.
Now I need to make the ships roll a bit as they turn (and level out as they start to fly straight again) much like real planes do in order to make a tight turn. My first thought was to do this every frame:
shipObject.eulerAngles.z = rigidbody.angularVelocity.y * rollAmount;
I'll use rollAmount as a constant to make more agile ships roll more.
However, the SmoothLookAt code doesn't affect the rigidbody and actually freezes the rotation in the start function (I tried removing that but no luck) so angularVelocity.y is allways 0. Next I tried to do the same but calculate the angularVelocity myself using with the values of eulerAngles.y from the previous and current frames
(current - previous) / Time.deltaTime
That sort of worked but the movement was extremely jerky and seemed to be flickering between a negative and positive rotation.
Any ideas of how to solve this - I'm a bit stuck? I'm looking for the kind of motion you get in Starcraft 2 air units if anyone's wondering what I mean.
The rolling won't affect the actual turning performance of the ship - it's just for show.
Thanks! :D
Your answer
Follow this Question
Related Questions
how to rotate a rigidbody to a point on a plane on mouse down 1 Answer
Gravity on a rotating platform 1 Answer
Aligning 2 Quaternions Using Torque 1 Answer
RigidBody AddForce not pushing rb to forward when adding angularVelocity 1 Answer
Angular Velocity is causing object to spin out of control 0 Answers