nyenye wrote:Okay I have two different questions. First of all say that it's a Top-Down view kind of game.
The first one is about "collisions" and the second one deals with Jumper and STI.
Thanks in advance.
- Collisions - I am using Hardon Collider, and till now very pleased, but right now I am dealing with collisions between two 'dynamic' entities and I get a not expected behaviour. The 'enemy' pushes the 'player'. Is this normal? Attached a video.
In this code below 'shape_a' is always the one colliding, and the one which should be separated.Code: Select all
function CollisionManager:resolveCollisions() -- For every dynamic collider do for _, dyn in ipairs(self.dynamics) do -- Check if active. If not active then it doesn't collide if dyn.is_active then -- if active then -- HardonCollider returns all collisions with the current dynamic collider (dyn) local collisions = self.hc:collisions(dyn) -- For each collision... for other, sv in pairs(collisions) do -- If other active... if other.is_active and ( dyn.mask[other.group] or dyn.mask[Globals.MASK_ALL]) then -- mask filters collisions. Player and Enemy always collide if other.mode == Globals.COLLIDER_DYNAMIC then -- If other is dynamic too... CollisionManager.resolveDynVsDyn(dyn, other, sv) -- resolve collision for dynamic objects. else CollisionManager.resolveDynVsOther(dyn, other, sv) end end end end end end
Maybe what happens is that the collision is checked two times? One for the player against enemy and second enemy against player. But I don't think it should because when it's resolved one time, its resolved for the two, right?Code: Select all
function CollisionManager.resolveDynVsDyn(shape_a, shape_b, sv) local entity_a = shape_a.entity local entity_b = shape_b.entity -- In the original code I had more things but it didn't work, so I simplified -- to the minimum (more or less like a dynamic vs static collision) entity_a:move(sv.x, sv.y) end
- Jumper / STI - Has anyone dealt with Jumper and STI? Is there a standard way to do it? Or do you have to make a matrix map with walkable tiles each time you change a map on Tiled? Or does anyone have a trick to make it more or less dynamic?
PD: game.love is attached
Collision between two dynamic entities will always push the other, since they are both dynamic. Its physics stuff in love2d