summaryrefslogtreecommitdiff
path: root/scripts/capsuleMove.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/capsuleMove.lua')
-rw-r--r--scripts/capsuleMove.lua18
1 files changed, 17 insertions, 1 deletions
diff --git a/scripts/capsuleMove.lua b/scripts/capsuleMove.lua
index e454b06..cfc4c85 100644
--- a/scripts/capsuleMove.lua
+++ b/scripts/capsuleMove.lua
@@ -6,6 +6,10 @@ return function(entities, id, dt)
return glfw.GetKey(window.win, key) == glfw.PRESS
end
+ local float = self.node._child.spring.spring.F
+ ode.BodyAddForce(self.physics._body, 0, float, 0)
+ self.node._child.spring.spring.F = 0
+
local yaw = math.rad(
self.node._child.p
.node._child.pivot
@@ -28,10 +32,22 @@ return function(entities, id, dt)
vel = vel - left
end
- vel = 1000 * vel:normalize()
+ vel = 2000 * vel:normalize()
x, y, z = ode.BodyGetLinearVel(self.physics._body)
if Vec3{x,y,z}:norm2() < 500 then
ode.BodyAddForce(self.physics._body, vel[1], vel[2], vel[3])
end
+
+ -- slow down
+ local horizontalDamping = 100
+ local verticalDamping = 5
+ ode.BodyAddForce(self.physics._body,
+ -horizontalDamping*x,
+ -verticalDamping*y,
+ -horizontalDamping*z)
+
+ if y < 0.3 and float > 0 then
+ ode.BodySetLinearVel(self.physics._body, x, 0, z)
+ end
end