Hi all,
After applying force to dynamic body, linear velocity is suddenly reduced after some time, when the force is no longer applied. I have reduced Y gravity to 0 in physics project settings, but otherwise I’m using default values.
I’m quite new to defold so I’m not sure if I’m missing anything, but I didn’t find anything in documentation that would explain it.
Gif of what is happening (white line is linear velocity)
Debug output
I have this script attached to my game object
go.property("forward_thrust", 100)
function init(self)
msg.post(".", "acquire_input_focus")
self.acceleration_forward = vmath.vector3()
end
function update(self, dt)
msg.post("#co", "apply_force", {force = self.acceleration_forward, position = go.get_world_position(".")})
local linvel_color = vmath.vector4(1, 1, 1, 1)
local forward_color = vmath.vector4(1, 1, 0.2, 1)
local linvel = go.get("#co", "linear_velocity")
print(linvel)
msg.post("@render:", "draw_line", {
start_point = go.get_world_position("."),
end_point = go.get_world_position(".") + self.acceleration_forward,
color = forward_color
})
msg.post("@render:", "draw_line", {
start_point = go.get_world_position("."),
end_point = go.get_world_position(".") + linvel * 5,
color = linvel_color
})
self.acceleration_forward = vmath.vector3()
end
function on_input(self, action_id, action)
local r = go.get_world_rotation()
if action_id == hash("up") then
self.acceleration_forward = vmath.rotate(r, vmath.vector3(0, self.forward_thrust, 0))
if action.pressed then
particlefx.play("l_thruster#thruster_particles")
particlefx.play("r_thruster#thruster_particles")
elseif action.released then
particlefx.stop("l_thruster#thruster_particles")
particlefx.stop("r_thruster#thruster_particles")
end
end
end
I should be on current version
Any idea what might it be happening?
Thank you