- Home /
Rigidbody slows down while turning using torque
I'm making a speedboat controller. Thrust is applied to the rigidbody by using AddForce (as long as the thrust button is pressed), and turning is tone by using AddTorque (as long as the left or right turning button is pressed). This works fine, but I've noticed that the rigidbody slows down while turning under thrust. My boat normally goes at about 50 km/h, but during a sharp continuous turn, it slows down to about 20 km/h. When I stop steering, the speed picks up again.
There is no friction or any other forces working on the rigidbody other than a thrust force and the torque steering. There is drag of course, but that stays the same, regardless of whether you are steering or not.
I'm not a physics expert, but is this normal behaviour, or am I doing something wrong? Should I just combat this by increasing the thrust during steering if I don't want this bevhaviour to be this pronounced?
Thanks!
Answer by Eno-Khaon · Mar 26, 2021 at 07:39 PM
Torque has no bearing on velocity in basic/game physics. After rotating the boat using torque, your velocity will remain unchanged until you apply a new force to push it in a new direction.
A boat's hydrodynamic forces come, in large part, from its shape. Turning a boat is primarily about redirecting its existing momentum using the rudder, so that it will continue moving "forward" throughout the turn.
With this in mind, getting a better physical response from the boat at a simple level can be done by redirecting your current velocity while you turn:
Quaternion lastRotation;
// ...
rb.AddRelativeTorque(turningTorque);
Quaternion currentRotation = transform.rotation;
Quaternion relativeRotation = currentRotation * Quaternion.Inverse(lastRotation);
rb.velocity = relativeRotation * rb.velocity;
rb.AddRelativeForce(accelerationForce);
lastRotation = currentRotation;
While it wouldn't be entirely true to life to translate the entire existing force per frame as per my example, this may help get you going in the right direction.
That said, it is also true to life that *some* speed will be lost while turning because redirecting ALL of the velocity is a fairly unreasonable task. The ideal is to minimize that reduction in speed, so cars/boats/etc. do what they can to conserve that momentum and redirect as much of it as they are able to.
That sounds like a neat idea, if your boat has a rudder. My speedboat is more of a jetboat (or a hovercraft with some serious drag), and the drifting aspect is part of the fun so I don't want to mess with the velocity directly. The more I play with it and think about it, it's logical that doing it this way slows down while rotating, as changing the direction the mass is already traveling in requires a lot of energy, which has to come from somewhere. I'm going to leave it as is, and tweak it so it's fun and part of the gameplay. Thanks for the tip though, I'm sure someone else in the future will be helped by this when trying to make something less drifting/energy losing!
Your answer
Follow this Question
Related Questions
Problems with Physics(Flipping strangely) 2 Answers
Setting a RigidBody's velocity messes with my custom gravity, not sure how to proceed. 0 Answers
VR Sword Physics, how to add force or velocity to the sword for impact when it hits an object 1 Answer
How would you code a Wind script? 1 Answer
How do I stop my Player (controlled by RigidBody) stopping after jumping? 0 Answers