How would I make a boat not travel when it is not on water?

Hi, so I have a boat for my game and it drives itself well on water… but the problem is it also drives well on other types of terrain as well including grass! So I was basically wondering if there would be a way to stop my boat from moving or travelling or gaining speed on grass because well, its grass. Thanks a lot! I hope this can be an easy fix as well, but if it isn’t well that’s okay as long as there’s an answer.

1 Like

Just shoot a ray straight down, then there will be a raycast result, image
which you can just check the material with!

How would I do that? Sorry, I am not that familiar with raycasting and if its easy can you please provide the code for me? I will learn from it. Thanks. Also is this an easier method than using Touched() event and getting material from that (is that even possible?)

Just read this article about it, really helpful:

Thanks but it seems pretty complicated. How would I create a ray that goes from the bottom of a part to what’s underneath it? How do I get the intersection? Could someone just provide a snippet of example code, I will get it if I see it in its working form. Thanks! In the meantime I will read.

Should get you in the correct direction.

 function RayDownY(position,Offset)
    		local ray = Ray.new(position, Vector3.new(0,-1000,0))
    		local objecthit, hitposition,normal,material = workspace:FindPartOnRayWithWhitelist(ray, {workspace.Terrain}, false, false)
    		if hitposition ~= nil then
    		return hitposition,material
    		end
    end

do not bother with the offset, just a remnant argument from older code

3 Likes

Why not just build a propeller boat?
They work pretty well in water, you just have to get the buoyancy right.
Here’s a simple one a made a while back, slightly updated, but you’ll get the idea.
https://www.roblox.com/library/6760832975/Boat

The reason why boats do not so this in real life is because they are a lot heavier.

Either you can increase the density and compensate by adding more blocks on (remember to keep the density below 1) this is the easiest solution. Also increase friction so that of it gets into contact with something you will need a lot of force to push it.

Or you could in theory use a raycast to determine whether you are in water or not but I don’t recommend using raycast because there are other more useful things to use raycast with.
Plus the issue is making the boat staying in water and not detecting when it is out of it.

Making a propeller boat would work as well. As it will be entirely dependant on the physics and you can keep things simple.

1 Like

Thanks for the code- it is really appreciated from my end! I will tweak it and see what else I can do with it.

I tried to make that but I don’t know, it doesn’t convert well over to big ships- and the propellers didn’t work when I welded them to the boat. If you know why, maybe I can try it again because the concept is very cool!

If you found another solution that’s fine.

I was working on something similar before and I was looking at different ways of motion. If you want to look at it I have left a file at the end

My view is to treat Roblox water physics as closely to water as possible.

I could also make for you a sample of how a propeller would work with the current water physics if you like :slight_smile:
WaterPhysics4Motions.rbxl (739.3 KB)


here is the propeller boat.

Pure Roblox physics. No coding at all.
I put a part on top because the propeller needs to be fully submerged to work properly

FYI the ship spins because some of the propeller dips out of the water.

https://gyazo.com/349cbbd07a424f893975a96e9e9b9a9d

1 Like

Thanks, someone has already shown me how propellor boats work but for the life of me I can’t seem to make it work on big ships. I’ll take a look though. I wonder how propellor boats can help me though, I just need the ship to stop immediately. Thanks.

1 Like

Bigger ships need more thrust to move them.
Also, the boat that I was linked you to uses the old style HingeSurfaces. Don’t weld the propellers to the boat because they won’t move.
You’ll need to put in HingeConstraints between the props and the hull, and make sure the Attachments are located so the HingeConstraint doesn’t cause the rotating Parts to touch any of the hull Parts.

Prop boats react in the water using ‘physics’ until they hit something solid. If your hull hits something solid then the force of the props can’t move the solid item and the boat stops or bounces off at an angle similar to the way it would in real water.

Go to the bottom part of your boat, go into its properties and in custom physical properties change friction and frictionweight to maximum as seen on the picture. This made my boat completely stop in place, unable to move on solid ground. :grinning:

But that’s if you are moving the boat with MoverConstraints.

My system uses propellers in the water to drive the boat, not MoverConstraints.

But your solution actually helps me out with another issue that I was having (since I’m not the OP in this post).

1 Like

I’ve been struggling with the same issue for about a month so I figured I should reply with the solution I found. :+1: