This is probably the last struggle for my True Tile Collision. Since I want to get rid of any intervention of built-in physics but needed some collision checking for moving platform objects. So I created my collision check (separated axis collision). I need some guesses what’s might be off.
Problem is when the platform moves and collides with the player.
--Platform x & y is on top left corner function player_on_platform(inst) --check if player is one pixel above inst.carry = collision_check_plat2play(inst, inst.POS + vmath.vector3(0,1,0)) --Check if player is on top and save their id end function h_moving_plat(inst,dt) local x = inst.POS.x --dcos and dsin are converted to work with degrees local dx = dcos(inst.time * 360 +(360*inst.offset.x)) * inst.radius.x inst.POS.x = inst.center.x + dx inst.spd.x = inst.POS.x -x --Movement speed to check in collision if inst.carry~=nil then inst.carry.POS.x = inst.carry.POS.x + inst.spd.x end end function h_collision_plat2play(inst) --platform against player local hsp = inst.spd.x if hsp~=0 then local player = collision_check_plat2play(inst, inst.POS) if player~=nil then if hsp>0 then player.POS.x = inst.POS.x + inst.width - player.hitbox_l elseif hsp<0 then player.POS.x = inst.POS.x - player.hitbox_r end end end end function v_moving_plat(inst,dt) local y = inst.POS.y local dy = dsin(inst.time * 360 +(360*inst.offset.y)) * inst.radius.y inst.POS.y = inst.center.y + dy inst.spd.y = inst.POS.y -y --Movement speed to check in collision if inst.carry~=nil then inst.carry.POS.y = inst.carry.POS.y + inst.spd.y end end function v_collision_plat2play(inst) --platform against player local vsp = inst.spd.y if vsp~=0 then local player = collision_check_plat2play(inst, inst.POS) if player~=nil then if vsp<0 then player.POS.y = inst.POS.y - inst.height - player.hitbox_t elseif vsp>0 then player.POS.y = inst.POS.y - player.hitbox_b end end end end
Added project if interested to look closer.
TileCollisionPlatformer.zip (153.1 KB)
P.S. I’m amazed how small size the project is.