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 BennyT

Hi all,

I am currently working on a sport game and I am having trouble bringing an entity to a complete stop.

When the opposition "tackles" (ie. collides) with the player entity, both entities need to come a complete stop and pause the game for a second or 2 so the opposition can get into position (the point of collision - 100 pixels from the tackle y co-ordinate). The tackle count then needs to increment by one.

The issue I got is that there are still collisions happening with each game tick and the tackle count increments so fast that my change possession method is called.

If anyone can help that would be great! Here is the collidesWith code for the enemy (opposition entity):

        collideWith: function(other, axis) {
        	console.log(axis);
        	this.afterTackle = true;
        	this.vel.x = 0;
        	this.vel.y = 0;
        	ig.game.player.vel.x = 0;
        	ig.game.player.vel.y = 0;
        	ig.game.referee.tackleCoordinates = [Math.round(ig.game.player.pos.x), Math.round(ig.game.player.pos.y - 100)];
        	ig.game.referee.tackleCount += 1;
                this.getIntoPosition(ig.game.referee.tackleCoordinates);
        }

1 decade ago by stillen

You can make a tackle timer.

When a collision happens check to see if the tackle timer is larger then the offset you need. In your example, 2 seconds. If the offset is past 2, allow the normal collision to happen and reset the timer to 0.

1 decade ago by BennyT

Hi Stillen,

Thanks for that suggestion, I will give it a go and report back on the implementation.

My main concern though will be with the vel and speed of the oppontent entity not fully slowing down even when I set the velocities to 0.

1 decade ago by stillen

You can access the other entity in the collision by the other parameter. You could do
other.vel.x = 0 for example.

Maybe I'm confusing how you want the game to stop. I would think you could also set up a flag in each entity that tells them not to play the game and reset the line so to speak.
Page 1 of 1
« first « previous next › last »