Hi I am having a bullet problem with my sprite. I want the bullet to shoot from my turret however it is shooting from the enemy tank body. Any suggestions to why this is? Help would be much appreciated.
//sprite names
this.enemy = this.scene.physics.add.sprite(x, y, ‘player2’, ‘tank1’);
this.turret = this.scene.physics.add.sprite(x, y, ‘player2’, ‘turret’);
//detect collisions
this.scene.physics.world.collide(this.enemy, playerBullets, enemyHitCallback, null, this);
this.scene.physics.world.collide(player, enemyBullets, playerHitCallback, null, this);
//enemy fire function
function enemyFire (enemy, player, time)
{
if(enemy.active === false)
{
return;
}
if((time - enemy.lastFired) > 1750)
{
enemy.lastFired = time;
var bullez = enemyBullets.get().setActive(true).setVisible(true);
if (bullez)
{
bullez.fire(enemy, player);
}
}
}
enemyFire(this.enemy, player, time, this);
}
}