How can i make my boat work?

both, i am using parts for some areas such as a boat landing area and the beach is terrain

1 Like

How about the water, part based or terrain? Because if a primary part of the map is smooth terrain you may want to use RayCasting in the 4 cardinal directions along as downwards; to check for a hitPart, hitPosition and or MaterialType and then compare it to the water if it’s not the water then you’d set your lock function to true and stop the boat from moving.

There are also many things you may want to take into account, say they can’t move forwards because something is blocking the forward path, you may want to look into ways of allowing them to still go backwards. Sometimes a good boat system can get rather complex, rather quick.

1 Like

water is terrain, i cba to make water out of parts. the boat can reverse already

1 Like

and how would i do camera manipulation to a custom camera while driving? i am used to still cameras. would i use render stepped?

1 Like

To make a custom Camera you’d need to use RenderStepped along with Enum.CameraType.Scriptable, if you know the decent cframe for it then it shouldn’t be too bad; just don’t forget to change it back when you to their previous camera settings when they leave the seat.

1 Like

yea, ok. thanks for your help.

1 Like

how would i use raycast to detect terrain? i have only used it in gun frameworks

tried this:

RunService.Heartbeat:Connect(function()
local RayCast = Ray.new(Boat.RayFrom.CFrame.p, (Boat.RayBlock.CFrame.p - Boat.RayFrom.CFrame.p).unit * 100)
    local ignore = {}
    local part, position = workspace:FindPartOnRay(RayCast, ignore, false, true)

    if part ~= "RayBlock" then
	    print("Ray Blocked")
    end
end)

but it didnt work

1 Like
local moveVectors = {
    ["Left"] = true, 
    ["Right"] = true,
    ["Front"] = true,
    ["Back"] = true,
}

local function checkVectors()
    for i,v in pairs(moveVectors) do
        local ray = Ray.new(Boat.PrimaryPart.CFrame.p, (i == "Left" and Boat.PrimaryPart.CFrame.rightVector * -2) or (i == "Right" and Boat.PrimaryPart.CFrame.rightVector * 2) or (i == "Front" and Boat.PrimaryPart.CFrame.lookVector * 2) or Boat.PrimaryPart.CFrame.lookVector * -2)
        local hit, hitPos, material = workspace:FindPartOnRayWithIgnoreList(ray, {Boat})
        if hit or hitPos or material then
             moveVectors[i] = false
        else
             moveVectors[i] = true
        end
    end
end

-- calling it in your heartbeat function 
game:GetService("RunService").Heartbeat:Connect(function()
     checkVectors()
     if (TValue > 0 and moveVectors["Front"]) or (TValue < 0 and moveVectors["Back"]) then
         Engine.Force = Vector3.new(0, 0, speed * TValue)
     else
         Engine.Force = Vector3.new();
     end
     if (SValue > 0 and moveVectors["Left"]) or (SValue < 0 and moveVectors["Right"]) then
         SForce.CFrame = DSeat.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(RotateSpeed * -SValue), 0)
    else
         SForce.CFrame = DSeat.CFrame
    end
end)
4 Likes

doesn’t seem to be working for part terrain
ill check it on normal terrain

1 Like

Alright, it should have worked, are you getting any errors?

1 Like

not currently. ill try it with terrain now

1 Like

Can you take a picture of your boat with the primary part selected because depending on the size of the primary part you may need to change the size of the ray cast.

1 Like

here:

1 Like

i am in my testing area rn because my map is secret :wink:
also, any idea why my camera script for it isnt working?

game:GetService("RunService").RenderStepped:Connect(function()
    if script.Parent.Occupant == game.Players.LocalPlayer.Character.Humanoid then
	    workspace.CurrentCamera.CFrame = script.Parent.Parent.Camera.CFrame
    end
end)
1 Like

Adjust the size of the ray casting then try again, and make sure to set the CurrentCamera type to Scriptable.

1 Like

ok, the boat stops when on land now but when you turn at the same time it can move

1 Like

So what you’re telling me is you can’t go forward and turn at the same time?

1 Like

you can turn and go forwards but this happens when on land: https://gyazo.com/2273e8e34cbcd7a61e1c1ddc307c8af3
i can turn to make it move on land as turning is still working on land

You may want to add a ray cast straight down and check if the material is water if not then kill the engine

ok, i have done this and it works 100% ty

(which post should i mark as the solution?)