Merge pull request #19 from jeremyshannon/main

Use add_velocity instead of set_velocity, to get rid of movement jitter
This commit is contained in:
Alexsandro Percy 2023-10-10 17:47:31 -03:00 committed by GitHub
commit c7e74ddaf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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