So I've made a boat, and in the boats hull theres a BodyForce instance with Y axis set to 26500. Im trying to make this reduce to 13000 when the boat either touches a block or the Terrain, I tried doing terrain in general, but that wouldnt work as Im using roblox water for the sea. I needed it to only work when it touched the Grassy block from default roblox terrain...
I tried making a script that was in the ships hull, but I actually forgot to save the game, so cant provide that. I'm not the best scripter although did watch some of the videos provided by roblox. If someone could give me a push in the right direction, would be much appreciated. Thank you in advance! =)
Rays are able to return terrain and Parts
Try using this function that I made:
function CastRay(Object,Distance) local ray = Ray.new( Object.Position, Object.CFrame.lookVector*Distance) local Hit = game.Workspace:FindPartOnRay(ray) return Hit end BoatHull = game.Workspace.BoatHull--you dont need this BoatHull.FrontSurface= "Motor" -- The motor represents where the ray is coming out from(you don't need this part) while wait() do --Example: local Ray = CastRay(BoatHull,1) print(Ray) ------------- end
If you want it to work like the touch event make sure the distance is set to 1 like I did.
Have any questions about rays or anything else feel free to ask me.
Want to learn about Rays read these pages:
http://wiki.roblox.com/index.php/Raycasting
http://wiki.roblox.com/index.php?title=Scripting_Book/Chapter_17
I'll give you the start but not the whole thing because you could at least make an effort to make a script.
game.Workspace.Boatpart.Touched:connect(function(Hit) end)
That's what I believe to be the start of that but I could be wrong, I'm a beginner scripter.