im tryin to make a platformer base to use for future projects, but when travelling in positive directions, the collision is seemingly not detected until a full pixel further than it should be
local xd=n.x+n.speed.x+n.w/2*sgn(n.speed.x) local yd=n.y+n.speed.y+n.h/2*sgn(n.speed.y) n.grounded=false n.walled=false if fget(mget(xd\8,(n.y+n.h/2)\8))==1 or fget(mget(xd\8,(n.y-n.h/2)\8))==1 then n.x=xd\8*8+(n.speed.x>0 and -1-n.w/2 or 8+n.w/2) n.walled=true n.speed.x=0 end if fget(mget((n.x+n.w\2)\8,yd\8))==1 or fget(mget((n.x-n.w\2)\8,yd\8))==1 then n.y=yd\8*8+(n.speed.y>0 and -1-n.h/2 or 8+n.h/2) n.grounded=true n.speed.y=0 end n.x+=n.speed.x n.y+=n.speed.y |
negative velocity position readings(continuously accelerating by -0.005 pixels/second/second)
INFO: y=10
INFO: y=10
INFO: y=10
INFO: y=10
INFO: y=10
positive velocity position readings(continuously accelerating by 0.005 pixels/second/second)
INFO: y=29.7242
INFO: y=29.8109
INFO: y=29.9025
INFO: y=29.999
INFO: y=29
negative velocity position readings(given a constant velocity of -0.005 pixels/second while pressed against wall)
INFO: y=10
INFO: y=10
INFO: y=10
INFO: y=10
INFO: y=10
positive velocity position readings(given a constant velocity of 0.005 pixels/second while pressed against wall)
INFO: y=29.9844
INFO: y=29.9883
INFO: y=29.9922
INFO: y=29.9961
INFO: y=29
this happens at any speed/width/height combination, and the readings are from the last 5 frames before a collision is registered
i have a feeling this is because of flooring but i dont know how i would fix it :3
lil demake of shazia from counterpact :3
controls:
AD: move
S: slide
left click: melee (reveals you for now)
right click: throw chain
F: sit
old versions: