forked from VoxeLibre/VoxeLibre
Modified collision detection to be based on velocity vector length rather than if the block you're touching is or is not air
This commit is contained in:
parent
aac55e9e38
commit
732296aa15
|
@ -88,14 +88,13 @@ function mcl_playerinfo:collision_detect(pos,player)
|
|||
for placement,coord in pairs(around_player) do
|
||||
local node = minetest.get_node(coord)
|
||||
local distance = vector.distance(pos, coord)
|
||||
local not_moving = vector.length(player:get_velocity()) < 3
|
||||
-- How far is the player from the block in the given direction and
|
||||
-- if the block is not air the player is colliding with it
|
||||
--print(node.name)
|
||||
--print(distance)
|
||||
if vector.distance(pos, coord) < too_close and node.name ~= "air" then
|
||||
if vector.distance(pos, coord) < too_close and not_moving then
|
||||
return false
|
||||
--Should be able to detect when your head is touching a slab
|
||||
elseif distance < slab_too_close and distance > too_close and placement == "front_ofplayerplus" and node.name ~= "air" then
|
||||
elseif distance < slab_too_close and distance > too_close and not_moving and placement == "front_ofplayerplus" then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -175,7 +175,6 @@ minetest.register_globalstep(function(dtime)
|
|||
--Check if the player should be sprinting
|
||||
|
||||
if not isNotColliding and ctrl.aux1 and ctrl.up and not ctrl.sneak then
|
||||
print("uwu")
|
||||
players[playerName]["shouldSprint"] = false
|
||||
elseif isNotColliding and players[playerName]["clientSprint"] or ctrl.aux1 and ctrl.up and not ctrl.sneak then
|
||||
players[playerName]["shouldSprint"] = true
|
||||
|
|
Loading…
Reference in New Issue