Game Development Community

How to make a boat float on water?

by Steve (All new 2 me) · in Torque Game Engine · 06/24/2004 (1:44 pm) · 29 replies

Hi,

Does anyone know how to make a boat (non-mountable) float on the water? This includes making it bob up and down in the water with the waves.

Also how would I make the particle effects such as waves crashing on the boat and the particles of the water splashing as the boat moves?

Thanks,
Steve

About the author

Recent Threads

Page «Previous 1 2
#1
06/24/2004 (1:53 pm)
There's a resource that does this. Search the resources for 'boat' and it'll come up.
#2
06/24/2004 (2:08 pm)
However if you want to do this yourself its not that difficult.

In a very simple implementation, you adjust the boats Z height according to the percentage its submerged, thats very eay to do :)

However if you dont want to/dont have the time to full write your own boat vehicle class, then check this out.
#3
06/25/2004 (1:21 pm)
That resource was a good start but left a lot to be desired...the boat was based on the hovercraft (flying vehicle) and some coding still needs to be done to get it to set down on the water.
#4
06/25/2004 (1:36 pm)
Yes, and it has a happen to fly, you touch land and you fly, you hit a wave your fly.
#5
06/27/2004 (8:58 pm)
Installed the patch, but there were issues which were already stated.
Issues :

1. Ship will fly when land is touched.
2. The boat falls extremely slow.
3. If mass is increased the boat will fall quickly, but will fall through the terrain.


Thanks for you help, but what I am looking for is a boat that will collide with the water (as well as bobbing up and down and sway in the water) terrain and create particle emitter when collisions is detected to show a kind of a splash.

How would I get started with doing something like this?

Thanks again everyone.
#6
06/28/2004 (5:53 am)
I played around with boats for a bit a while ago. The best starting point for new types of vehicles is the wheeled vehicle class as it free-falls correctly and you can always just not add wheels. From there I just added thrust forces that I copied from the other vehicle classes and put a check in to only apply them when there is enough water coverage. Changing the density of the vehicle is enough to make it float (make it less than the density of the water). Add in a stabilizing force (the other vehicle classes have these) thats relative to the water coverage to keep it from flipping over while its in the water.

I think I have a bit of code I can post when I get home if you want.

The splashing effect is already built into the engine. The 'FoamEmitter' property or something, cant remember.

There are problems with making it bounce in the waves. The waves are not sychronized over the network and they are not even generated at all on dedicated servers. You're on your own on that.
#7
06/28/2004 (12:25 pm)
@Eric: Thanks the code will be helpful for me.

I'll do some research with the boat bouncing on the waves and post the results/code if I successfully implement it.
#8
06/28/2004 (10:00 pm)
Sounds like a good resource to me.... ;-)
#9
06/30/2004 (3:01 pm)
Hmm my code is a little less organized than I thought. I posted some stuff here http://www.garagegames.com/mg/forums/result.thread.php?qt=18877 that should help you get thrusting and turning without the wheels touching the ground. Might get you started.
#10
02/25/2005 (6:15 am)
Hi Steve,

I wonder if you succesfully implemented the floating boat. Did you post your code anywhere? I want to make the similar game and I have problems. Maybe you could help me?

best regards
Richard
#11
02/26/2005 (10:43 am)
@Richard
I started a boat based off of the wheeled vehicle class.
Changed the code so the wheels would collide with the water block and just made the wheels invisible. But that was just the start to alot of changes i had planned to get a real boat. i was going to rip alot of stuff out and add some code i found in the hover vehicle class.

As for bouncing with waves, that would need some major engine code changes as the water mesh is generated on the client only. All the server sees is a flat water block.

i started a thread here www.garagegames.com/mg/forums/result.thread.php?qt=22415
but moved on to other projects afterwards.

One idea i was gonna try out is give each waterblock a var that described its type (calm, wavy, storm ..etc) and have the vechicle attempt to bounce according to the water type. But it might be hard trying to get it to match up with how the waves are moving.
#12
03/01/2005 (2:18 am)
@Chris,
why you didn't use the hover vehicle class? Is it not good enough for the floating boat (I don't know this class exactly, maybe my question is stupid)? Which features have you used from wheeled vehicle and which from hover?
#13
03/01/2005 (7:12 am)
I was going to start from scratch, but lacked understanding of the engine. I was thinking of having an boat and on each corner a point that I would use for physics. These points would colide with the water, you could adjust where the points are on the boat and that's how high it sits in the water. I then though of a boat running up a ramp or hitting a wave, after it contacts the water again, it sinks down a bit and comes back up, so it bounces.

So if you modify the water code to generate the mesh on the server and the boat is sitiing still in wavy water it would act like this...
A wave comes in and hits the front of the boat, the front 2 collision points ride up the front of the wave then come down the back , the back of the boat rises from the rear 2 collision points. The front 2 shocks on the front collision points give in a bit and the front sinks a lil underwater, then rises back up.


I then looked at the vechicle classes and seen the wheeled vechicle did what I planned to do. It has 4 points for collisions (wheels) and is able to bouce when it hit the ground (shocks). So I started some mods on that.

I modified the wheels collision code to collide with water. (Just added a mask in the collision masks). Tested it out, the car was then driving on water, but had a few problems. The wheels would then go under the waterblock when you hit the terrian or a ramp and the car sinks to the bottom. For some reason the collision with the waterblock is not as good as with the terrain. In the hover vechicle class there is some code to detect when you are in a waterblock and to apply upwards force to the point that is submerged.

That's as far as I got before I moved on to other things. It worked pretty well but still needed many things done well cuz it drove like a car on water, not a boat.

Btw this is back on my todo list.
#14
10/09/2005 (11:36 am)
Ok new idea.....
1. make a ship model
2. then rig it with the car rigs
3. write a script that enables the ship to be on water
4. now the ship has the 4 dynamic invisble tires and should move realisticaly swaying back and forth
#15
10/09/2005 (11:38 am)
With so much talk about boats recently, it would be nice to have either the hover class or a decent boat resource be put in a central place on the forums, like a sticky or something.
#16
10/09/2005 (12:01 pm)
@Tim
Thats what i was doing in the posts above.
The collisions take place on the server. All the server sees is a flat plane for collisions.
The waves are rendered on the client only , they have nothing to do with collisions.
You need to rewrite the water code to do this properly.
#17
10/09/2005 (12:07 pm)
If you just want a boat to do nothing but bob up and down... just make a boat... give it the animation (bobbing up and down etc) and place it on the water.


I think thats how GG did it for the TSE demo.
#18
10/09/2005 (1:09 pm)
Thats good for just having one in the background.
#19
10/11/2005 (5:39 am)
You could always use the Rigid shape class..
If you alter the density, it'll float on water.. It won't bob around on waves though as the waves are only a client side rendering effect as far as I know.
#20
10/11/2005 (8:29 am)
Juan yes it is.
I was not happy with the results of the few easy methods ive used.
For a good game with proper physics and "wave bouncing" will require many many changes to the engine. It will require alot of time but it will be worth it,
Page «Previous 1 2