Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can Body Positions Restrict Parts to a Y-Plane by Ignoring Physics?

Asked by 4 years ago
Edited 4 years ago

Hopefully I can explain this issue. So essentially, I am making boats that need to stay on a particular Y-Plane (aka, the sea level). I have been using BodyPositions, with the maxforce in the Y direction set to infinity, to do this. This works great until I try to run the boat up any kind of slant leading up out of the water. The boat can simply go up the ramp onto an island. Is there any way to restrict movement onto a higher Y-Plane indefinitely, even if there is a solid slope to move the model up? Feel free to ask questions about how my boat actually operates if that is relevant (because I'm not sure what is). Thanks in advance.

Drive Script (inside seat):

script.Parent.MaxSpeed = 40
maxspeed = script.Parent.MaxSpeed
script.Parent.BodyPosition.position = script.Parent.Position--------------------DO NOT CHANGE ANYTHING!
script.Parent.BodyGyro.cframe = script.Parent.CFrame
value1 = 0
while true do
wait()
if script.Parent.Throttle== 1 then
if value1 < maxspeed then value1 = value1 + 0.5 end
script.Parent.Parent.Driving.Value = true
script.Parent.BodyVelocity.velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Parent.Left.Value = false
script.Parent.Parent.Right.Value = false
end
if script.Parent.Throttle == 0 then
value1 = 0
script.Parent.Parent.Driving.Value = false
script.Parent.BodyVelocity.velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Parent.Left.Value = false
script.Parent.Parent.Right.Value = false
end
if script.Parent.Throttle== -1 then
if value1<31 then value1 = value1+1 end
script.Parent.Parent.Driving.Value = true
script.Parent.BodyVelocity.velocity = script.Parent.CFrame.lookVector*-value1
script.Parent.Parent.Left.Value = false
script.Parent.Parent.Right.Value = false
end
if script.Parent.Steer == 1 then
script.Parent.BodyGyro.cframe = script.Parent.BodyGyro.cframe * CFrame.fromEulerAnglesXYZ(0,-.01,0)
script.Parent.Parent.Driving.Value = true
script.Parent.Parent.Right.Value = true
script.Parent.Parent.Left.Value = false
end
if script.Parent.Steer == -1 then
script.Parent.BodyGyro.cframe = script.Parent.BodyGyro.cframe * CFrame.fromEulerAnglesXYZ(0,.01,0)
script.Parent.Parent.Driving.Value = true
script.Parent.Parent.Left.Value = true
script.Parent.Parent.Right.Value = false
end
end
0
You could put a line of code in your drive script to move the boat backward when it detects the Y direction changing OBenjOne 190 — 4y
0
But that is more of a work around OBenjOne 190 — 4y
0
How does the boat move? I think if you are using position or CFrame that could explane why the movement is overpowering the bodypositions. OBenjOne 190 — 4y
1
The boat's probably moving up slopes because of the bodyvelocity. On collision with anything that isn't water, try setting max bodyvelocity forces to 0, and the bodyposition should drag the boat back down. whenallthepigsfly 541 — 4y
0
How would you make something happen "on collision"? corncob567 275 — 4y

Answer this question