1 decade ago by capgun
Hi guys, i've been having some trouble understanding the entity collision system.
I have a troop class and a base class - what i'm trying to achieve is:
while troop is colliding with base
- attack base over and over
This is what i've tried, I'm not understanding how to run the check method for constant collision detection. Any help would be very appreciated.
I have a troop class and a base class - what i'm trying to achieve is:
while troop is colliding with base
- attack base over and over
This is what i've tried, I'm not understanding how to run the check method for constant collision detection. Any help would be very appreciated.
attack: function(target) {
while (target.health > 0) {
if (this.attackTimer.delta() > 0) {
target.receiveDamage(this.attackPower, this);
}
this.attackTimer.set(this.attackTime);
}
},
check: function(other) {
if (other instanceof EntityEnemyBase) {
this.attack(other);
}
},
