Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by gosub

I'm working on a demo where the player can "push" other objects (such as crates/boxes) around the map.

My player has a collision type of PASSIVE and my boxes have a collision type of ACTIVE. Additionally, the box have a very high friction value (1000) so they stop after being pushed by the player.

All is working well with the exception of trying to push the boxes from the top. In this case the boxes won't budge. My hunch is that it has something to do with collision for side scrolling games where the player can stand on platforms and such. My demo, however, is top down.

Any pointers are appreciated! :)

1 decade ago by wicht

I don't think that this will work out with the built-in collision detection.
Problem is the seperateOnYAxis method of the Entity object (you guessed correctly):
else if( bottom.standing || top.vel.y > 0 ) {

your top entity (player) has a positive y-velocity, as it moves down.

without changing the engine, you can't do it with the COLLIDES.ACTIVE/PASSIVE stuff. (as far as i see)

To accomplish your goal, you have to check your collisions for yourself.
Just use the two collision groups (Entity.TYPE.A/B) and utilize the check methods to do your pushing.
This way is infact quite better, because you can get a better result through custom logic (like pushing slows the player down, different weights of the crate etc.)

1 decade ago by dominic

Yes, it is because of a special collision response used in side scrollers. Sorry about that.

Fixed it in the current dev version (git repo) by checking for gravity - which should only be there for side scrollers:

else if( ig.game.gravity && (bottom.standing || top.vel.y > 0) ) {	

1 decade ago by gosub

Thanks dom, that fixes my issue.

I'll probably need to look into what wicht suggested as well since I'd like to make it so the player can't push a box which would in turn push another box.
Page 1 of 1
« first « previous next › last »