mirror of
https://github.com/SmallJoker/boost_cart.git
synced 2024-11-27 17:03:44 +01:00
Change Y rotation from 45° to 30°. Only send velocity when required.
Smoother position correction when the X,Y,Z directions weren't changed
This commit is contained in:
parent
4498605509
commit
ca55c6f3c0
@ -214,6 +214,7 @@ function cart_entity:on_step(dtime)
|
|||||||
local dir, switch_keys = boost_cart:get_rail_direction(
|
local dir, switch_keys = boost_cart:get_rail_direction(
|
||||||
pos, cart_dir, ctrl, self.old_switch, self.railtype
|
pos, cart_dir, ctrl, self.old_switch, self.railtype
|
||||||
)
|
)
|
||||||
|
local dir_changed = not vector.equals(dir, self.old_dir)
|
||||||
|
|
||||||
local new_acc = {x=0, y=0, z=0}
|
local new_acc = {x=0, y=0, z=0}
|
||||||
if stop_wiggle or vector.equals(dir, {x=0, y=0, z=0}) then
|
if stop_wiggle or vector.equals(dir, {x=0, y=0, z=0}) then
|
||||||
@ -230,7 +231,7 @@ function cart_entity:on_step(dtime)
|
|||||||
update.vel = true
|
update.vel = true
|
||||||
else
|
else
|
||||||
-- Direction change detected
|
-- Direction change detected
|
||||||
if not vector.equals(dir, self.old_dir) then
|
if dir_changed then
|
||||||
vel = vector.multiply(dir, v3_len(vel))
|
vel = vector.multiply(dir, v3_len(vel))
|
||||||
update.vel = true
|
update.vel = true
|
||||||
if dir.y ~= self.old_dir.y then
|
if dir.y ~= self.old_dir.y then
|
||||||
@ -352,29 +353,37 @@ function cart_entity:on_step(dtime)
|
|||||||
anim = {x=2, y=2}
|
anim = {x=2, y=2}
|
||||||
end
|
end
|
||||||
self.object:set_animation(anim, 1, 0)
|
self.object:set_animation(anim, 1, 0)
|
||||||
|
|
||||||
|
-- Change player model rotation, depending on the Y direction
|
||||||
if player and dir.y ~= old_y_dir then
|
if player and dir.y ~= old_y_dir then
|
||||||
local feet = {x=0, y=0, z=0}
|
local feet = {x=0, y=0, z=0}
|
||||||
local eye = {x=0, y=-4, z=0}
|
local eye = {x=0, y=-4, z=0}
|
||||||
feet.y = boost_cart.old_player_model and 6 or -4.2
|
feet.y = boost_cart.old_player_model and 6 or -4
|
||||||
if dir.y ~= 0 then
|
if dir.y ~= 0 then
|
||||||
-- TODO: Find a better way to calculate this
|
-- TODO: Find a better way to calculate this
|
||||||
if boost_cart.old_player_model then
|
if boost_cart.old_player_model then
|
||||||
feet.y = 6 + 1.5
|
feet.y = feet.y + 2
|
||||||
feet.z = -dir.y * 7
|
feet.z = -dir.y * 6
|
||||||
else
|
else
|
||||||
feet.y = -4.2 + 3
|
feet.y = feet.y + 4
|
||||||
feet.z = -dir.y
|
feet.z = -dir.y * 2
|
||||||
end
|
end
|
||||||
eye.z = -dir.y * 10
|
eye.z = -dir.y * 8
|
||||||
end
|
end
|
||||||
player:set_attach(self.object, "", feet,
|
player:set_attach(self.object, "", feet,
|
||||||
{x=dir.y * -45, y=0, z=0})
|
{x=dir.y * -30, y=0, z=0})
|
||||||
player:set_eye_offset(eye, eye)
|
player:set_eye_offset(eye, eye)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if update.vel then
|
||||||
self.object:set_velocity(vel)
|
self.object:set_velocity(vel)
|
||||||
|
end
|
||||||
if update.pos then
|
if update.pos then
|
||||||
|
if dir_changed then
|
||||||
self.object:set_pos(pos)
|
self.object:set_pos(pos)
|
||||||
|
else
|
||||||
|
self.object:move_to(pos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ function boost_cart:manage_attachment(player, obj)
|
|||||||
default.player_attached[player_name] = status
|
default.player_attached[player_name] = status
|
||||||
|
|
||||||
if status then
|
if status then
|
||||||
local y_pos = self.old_player_model and 6 or -4.2
|
local y_pos = self.old_player_model and 6 or -4
|
||||||
player:set_attach(obj, "", {x=0, y=y_pos, z=0}, {x=0, y=0, z=0})
|
player:set_attach(obj, "", {x=0, y=y_pos, z=0}, {x=0, y=0, z=0})
|
||||||
player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
|
player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user