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):
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); }