Hello
I am writing a game where players can control a few vehicles. Most of them are water based. Submarines, boats, & aircraft carriers to name a few. I have done some testing with applying impulses to my vehicles for control but it was a bit clunky. I have a few basic questions.
How would I steer say a boat in a FluidVolume?
How would I allow a submarine to surface and dive? I did try changing the mass but this felt like a bad way to accomplish my goal.
Can the FluidVolume have waves to simulate a rough sea?
Can I make a FluidVolume an infinite plane?
If I did make the FluidVolume an infinite plane could a static mesh be placed in the middle of it to simulate land?
Thank you.
Objects submerged in FluidVolumes
Re: Objects submerged in FluidVolumes
There's quite a few options depending on the type of boat and what kind of control you want. Most of them will involve some method of fighting against sideways drift.How would I steer say a boat in a FluidVolume?
The simplest method of fighting sideways drift is to measure the sideways velocity and subtract it out. The dot product of a direction and the velocity gives the velocity in that direction, so to eliminate all sideways drift:
Code: Select all
entity.LinearVelocity -= entity.OrientationMatrix.Right * Vector3.Dot(entity.OrientationMatrix.Right, entity.LinearVelocity);
For forward and back motion, a simple approximation is to apply impulses in the forward and back directions. To limit the speed, either apply a drag force or explicitly clamp the speed that the acceleration is allowed to achieve. To explicitly clamp it, measure the current speed using the dot product like before and use it to limit the acceleration. Turning can work similarly; dot(direction, angularVelocity) gives angular velocity around that direction.
The simplest approach would be to give it neutral buoyancy and then to apply up and down impulses. For a somewhat more physical approach that doesn't require modifying the entity itself, add an entry to the FluidVolume.DensityMultipliers dictionary.How would I allow a submarine to surface and dive? I did try changing the mass but this felt like a bad way to accomplish my goal.
Not at the moment. The FluidVolume could be modified to support it, though it would take some effort.Can the FluidVolume have waves to simulate a rough sea?
I have some plans to add in some form of waves eventually (along with a general FluidVolume rewrite; it's extremely old), but there's a lot of stuff that needs to get done first. I would not be surprised if it took until 2016 for me to get around to it.
The surface could be defined as one really big triangle, which could approximate infinity.Can I make a FluidVolume an infinite plane?
You could also modify the FluidVolume directly. This would involve setting the bounding box to basically-infinite (float.MaxValue along horizontal extents), removing the filter against surfaceTriangles in the AnalyzeEntry function, and setting the surfaceTransform appropriately (its position needs to be aligned with the surface of the water).
Yup!If I did make the FluidVolume an infinite plane could a static mesh be placed in the middle of it to simulate land?