mirror of
https://github.com/APercy/automobiles_pck
synced 2025-07-30 01:55:49 +02:00
friction adjusts
This commit is contained in:
parent
3ae7c0df8f
commit
981c5931d4
@ -27,6 +27,7 @@ function automobiles.control(self, dtime, hull_direction, longit_speed, longit_d
|
||||
|
||||
local player = minetest.get_player_by_name(self.driver_name)
|
||||
local retval_accel = accel;
|
||||
local stop = false
|
||||
|
||||
-- player control
|
||||
if player then
|
||||
@ -64,24 +65,26 @@ function automobiles.control(self, dtime, hull_direction, longit_speed, longit_d
|
||||
|
||||
--break
|
||||
if ctrl.down then
|
||||
if math.abs(longit_speed) > 0 then
|
||||
--[[if math.abs(longit_speed) > 0 then
|
||||
acc = -5 / (longit_speed / 2) -- lets set a brake efficience based on speed
|
||||
end
|
||||
end]]--
|
||||
|
||||
--total stop
|
||||
--wheel break
|
||||
if longit_speed >= 0.1 then
|
||||
acc = -1
|
||||
if longit_speed > 0 then
|
||||
acc = -5
|
||||
if (longit_speed + acc) < 0 then
|
||||
acc = longit_speed * -1
|
||||
end
|
||||
end
|
||||
if longit_speed <= -0.1 then
|
||||
acc = 1
|
||||
if longit_speed < 0 then
|
||||
acc = 5
|
||||
if (longit_speed + acc) > 0 then
|
||||
acc = longit_speed * -1
|
||||
end
|
||||
end
|
||||
|
||||
if math.abs(longit_speed) <= 0.1 then
|
||||
-- do not like it here, but worked better
|
||||
acc = 0
|
||||
--self.object:set_acceleration(zero)
|
||||
self.object:set_velocity(vector.new())
|
||||
if abs(longit_speed) < 0.2 then
|
||||
stop = true
|
||||
end
|
||||
end
|
||||
|
||||
@ -136,7 +139,7 @@ function automobiles.control(self, dtime, hull_direction, longit_speed, longit_d
|
||||
|
||||
end
|
||||
|
||||
return retval_accel
|
||||
return retval_accel, stop
|
||||
end
|
||||
|
||||
|
||||
|
@ -2,13 +2,15 @@ local min = math.min
|
||||
local abs = math.abs
|
||||
|
||||
function automobiles.physics(self)
|
||||
local friction = 0.99
|
||||
local vel=self.object:get_velocity()
|
||||
-- dumb friction
|
||||
--[[if self.isonground and not self.isinliquid then
|
||||
self.object:set_velocity({x= vel.x> 0.2 and vel.x*mobkit.friction or 0,
|
||||
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 > 0.2 and vel.z*mobkit.friction or 0})
|
||||
end]]--
|
||||
z=vel.z*friction})
|
||||
end
|
||||
|
||||
-- bounciness
|
||||
if self.springiness and self.springiness > 0 then
|
||||
|
@ -6,7 +6,7 @@ roadster.LONGIT_DRAG_FACTOR = 0.16*0.16
|
||||
roadster.LATER_DRAG_FACTOR = 30.0
|
||||
roadster.gravity = automobiles.gravity
|
||||
roadster.max_speed = 10
|
||||
roadster.max_acc_factor = 4
|
||||
roadster.max_acc_factor = 6
|
||||
roadster.max_fuel = 10
|
||||
|
||||
roadster.front_wheel_xpos = 10.26
|
||||
|
@ -348,8 +348,8 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
||||
end
|
||||
end
|
||||
|
||||
local curr_pos = self.object:get_pos()
|
||||
if is_attached then --and self.driver_name == self.owner then
|
||||
local curr_pos = self.object:get_pos()
|
||||
local impact = automobiles.get_hipotenuse_value(velocity, self.lastvelocity)
|
||||
if impact > 1 then
|
||||
--self.damage = self.damage + impact --sum the impact value directly to damage meter
|
||||
@ -432,6 +432,8 @@ minetest.register_entity("automobiles_roadster:roadster", {
|
||||
-- end correction
|
||||
accel.y = -automobiles.gravity
|
||||
|
||||
self.object:set_pos(curr_pos)
|
||||
self.object:set_velocity(velocity)
|
||||
self.object:set_acceleration(accel)
|
||||
|
||||
if newyaw~=yaw or newpitch~=pitch then self.object:set_rotation({x=newpitch,y=newyaw,z=0}) end
|
||||
|
Loading…
Reference in New Issue
Block a user