|
| 02 Apr 2016 01:09 AM |
I've been working on trying to stop the momentum after a body thruster sends the part forward. This is what I got:
bt.Force = Vector3.new(-300, bt.Force.Y, bt.Force.Z)
local initialX = body.Main.Position.X local initialZ = body.Main.Position.Z local currentX = body.Main.Position.X local currentZ = body.Main.Position.Z while true do initialX = body.Main.Position.X initialZ = body.Main.Position.Z wait(1) currentX = body.Main.Position.X currentZ = body.Main.Position.Z if currentX - initialX < 1 and currentX - initialX > -1 then if currentZ - initialZ < 1 and currentZ - initialZ > -1 then bt.Force = Vector3.new(0, bt.Force.Y, bt.Force.Z) end end end
But it seems to go backwards instead. Help? |
|
|
| Report Abuse |
|
|
| |
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 02 Apr 2016 01:38 AM |
| Scale the force proportionally with the forward force. So if the forward thrust is 100 newtons and you have an opposing force of 100 newtons, the forward thrust will decrease. Since the forward thrust has decreased the opposing force will also need to decrease since it's now, say 90 newtons forward and 100 newtons backwards. Since the backwards force is greater than the forward it will start sending the object in reverse. |
|
|
| Report Abuse |
|
|
|
| 02 Apr 2016 01:47 AM |
| So I should make 2 bodythrusts? To go opposite directions? If not, how do I counter it? |
|
|
| Report Abuse |
|
|
| |
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 02 Apr 2016 02:22 AM |
| You could add a second one that is the opposite of the initial one and update them synonymously, probably the easiest solution. May not be the best, but it will work if you don't want to do math. |
|
|
| Report Abuse |
|
|
|
| 02 Apr 2016 02:45 AM |
It's still going, I did the wrong thing.
local bt = part.BodyThrust local brt = part.BrakeThrust
-- Go
if key.KeyCode == Enum.KeyCode.W then brt.Force = Vector3.new(0, bt.Force.Y, bt.Force.Z) bt.Force = Vector3.new(300, bt.Force.Y, bt.Force.Z) end
wait(x)
-- Stop
if key.KeyCode == Enum.KeyCode.W then brt.Force = Vector3.new(-300, bt.Force.Y, bt.Force.Z) end |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
|
| 02 Apr 2016 06:18 AM |
| http://forum.roblox.com/Forum/ShowPost.aspx?PostID=186559318 |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 02 Apr 2016 08:17 AM |
| If you just want to make the part stop moving, but in a BodyVelocity instance with a Velocity of (0, 0, 0) and a MaxForce > 0 |
|
|
| Report Abuse |
|
|