Use add_velocity instead of set_velocity, to get rid of movement jitter

This commit is contained in:
Jeremy 2023-09-30 18:37:10 -07:00
parent 7a73f477b0
commit e9bbb1d001
2 changed files with 6 additions and 5 deletions

View File

@ -7,9 +7,9 @@ function automobiles_lib.physics(self)
-- dumb friction
if self.isonground and not self.isinliquid then
--minetest.chat_send_all('okay')
self.object:set_velocity({x=vel.x*friction,
y=vel.y,
z=vel.z*friction})
self.object:add_velocity({x=vel.x - vel.x*friction,
y=0,
z=vel.z - vel.z*friction})
end
-- bounciness
@ -33,7 +33,7 @@ function automobiles_lib.physics(self)
self.collided = false
end
self.object:set_velocity(vnew)
self.object:add_velocity(vector.subtract(vel, vnew))
end
-- buoyancy

View File

@ -98,7 +98,8 @@ function automobiles_lib.ground_get_distances(self, radius, axis_distance)
self._last_front_detection = rear_obstacle_level.y
--here we need to set the collision effect
self.object:set_acceleration({x=0,y=0,z=0})
self.object:set_velocity({x=0,y=0,z=0})
local oldvel = self.object:get_velocity()
self.object:add_velocity(vector.subtract(vector.new(), oldvel))
end
end