1 decade ago
by city41
In a collision map you can use the "one way" tiles to set a tile such that an entity can go through it in one direction, but not the opposite direction. For example you can jump up through a platform, but still end up landing on it.
I want to do the same thing for two entities. So if the player entity is coming from below the other entity, they don't collide. If the player is coming from above the entity, they do collide. Anyone ever done this?
I'm thinking I'll end up extending ig.Entity.solveCollision to account for this case, but if anyone has any ideas I'd love to hear them.
1 decade ago
by lazer
I've done this, but can't remember how off the top of my head. Can dig through my old code when I get home tonight.
What about setting collision to NEVER when the bottom entity touches the 'platform' entity (I know it may not be a platform, it's just easier to categorize) and its pos.y >= platformEntity.pos.y + platformEntity.size.y, then setting it back to whatever its collision was before when the player's entity.pos.y is <= platformEntity.pos.y?
Eh..I'm just brainspewing here. There is more than likely a much more elegant way to do it.
1 decade ago
by city41
If you can find your old code that'd be awesome.
I plan to play with the NEVER idea. I was also thinking in solveCollision, if the platform entity is set to say ONE_WAY (a new flag I'd add), then if the player's y velocity is upwards, ignore the collision, otherwise treat the collision as if the platform was set to FIXED
1 decade ago
by city41
I found a pretty simple solution to this. It&
039;s a bit course and it might prove to have issues down the road, but works for now. I just turned #collides
into a property for my player entity:
// inside EntityPlayer.init
Object.defineProperty(this, 'collides', {
get: function() {
if(this.vel.y < 0) {
return ig.Entity.COLLIDES.NONE;
}
return ig.Entity.COLLIDES.PASSIVE;
}
});
Page 1 of 1
« first
« previous
next ›
last »