2D Boat controlling physics
I'm working on a top-down 2D boat game with Unity3D. I couldn't able to understand how to implement physics of rudder controlling. My physics knowledge is not enough to think how rudder dynamics work. How rudder dynamics works in water? Can you help me for finding a starting point for this? Since I'm not able to think any solution for this, I can't provide an example code. EDIT: I'm trying to apply a force to rigidbody2D of the ship at the point of rudder with angle of the rudder. But I couldn't able to make something working Sample Code I draw a sketch. Red point is location of rudder. I'm trying to apply a force at that point with angle of rudder relative to ship heading on each Update. How can I do this?
The simplest, modestly realistic, model I can think of would be parameterized by the following:
- Mz The Turning Moment of the ship about the steering (ie Z or yaw) axis;
- L/2 The distance of the rudder from the turning axis, approximated as 1/2 the ship’s length L;
- v The current linear velocity of the ship (relative to the water, not the land nearby, so take into account any current).;
- w The current rotational (yaw) velocity of the ship about the Z-axis, measured CCW in radians per second;
- p0,p1,p2 The constant, linear and quadratic coefficients respectively of angular friction (ie resistance to turning) for the water (these control how quickly the ship stops turning when the rudder returns to straight, and impose a limitation on how sharply the rudder can be turned before losing any effect.)
- A the area of the rudder;
- d the density of the water.
- theta the current rudder angle measured CCW from straight back in radians
- heading the current heading measured CCW from origin direction in radians.
- delta-t is your time interval.
- Cd is coefficient of increased drag due to a non-neutral rudder position.
Then the relevant equations of motion can be derived something like this:
- Turning torque from rudder Tr == sin(theta) * A * v * d * L/2
- Friction torque from water Tw == p0 + p1 * w + p2 *
- Net torque T == max(0, abs(Tr) – abs(Tw)) * sign(Tr)
- w’ == w + T / Mz
- heading’ == heading + (w’ + w) * delta-t / 2
- Drag on forward motion increases by Cd * abs(sin(theta)) * **A * v * d
I think I have the signs correct, but that can be corrected if necessary by multiplying T by -1 in either equation (3) or (4).
By playing around with the parameters you should even be able to get an appropriately different feel for larger vessels compared to smaller ones. You should also set a modest limit on how fast the rudder can be turned, and prevent it from being turned further once Tw exceeds Tr.
Setting p0 greater than zero will nicely model the fact that ship have no steerageway below a minimum speed.
Calculation of Moments of Inertia – For ships of the same style but different sizes, the moment of inertia should vary linearly in the mass of the ship, and as the square of the length of the ship, as a first approximation.
Added Equation (6) above and corresponding drag coefficient; and
corrected equation (1) with additional factor L/2.
If the rudder turns left /, the boat turns left.
If the rudder turns right \, the boat turns right.
The more you turn the rudder, the greater the turn the boat takes. This assumes the rudder never turns 90+ degrees.
The / and \ assume the boat is facing up ^.
^ | | | | --- / <---rudder
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Entertainment & General News
- Games & eSport