Drewrg 0 Report post Posted November 18, 2016 Hello! I'm having a hell of a time trying figure out how to change Phaser Weapon plugins bullet speed after it's been shot. I also set "weapon.bulletSpeed" negative value, because by default it was going in opposite direction. I attached weapon to a spaceship sprite, but on "weapon.fire()" bullet goes backwards. Weapon definition. addWeapon: function(target) { var weapon; var weapon; weapon = game.add.weapon(100, 'bullet'); weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; weapon.bulletAngleOffset = 90; weapon.bulletSpeed = 5; weapon.trackSprite(target, (this.ship.height), 0); weapon.trackRotation = true; weapon.fireRate = 200; weapon.bulletRotateToVelocity = false; weapon.onFire.add(function() {this.blastSound.play()},this); return weapon; } this.ship = this.add.sprite(this.world.centerX, this.world.centerY +300, 'ship'); this.ship.anchor.setTo(0.5, 0.5); this.ship.scale.setTo(0.22); this.ship.angle = -90; game.physics.arcade.enable(this.ship); this.ship.body.drag.set(70); this.ship.body.maxVelocity.set(220); this.weapon = this.addWeapon(this.ship); I am trying to set the direction of the bullet to opposite, so I don't have to set bulletSpeed to negative value. change every bullets anchor. change the speed of particular bullet after it's been shot. It would be grate to hear any suggestion. Тhank you in advance. Quote Share this post Link to post Share on other sites
drhayes 337 Report post Posted November 18, 2016 I don't know exactly what's wrong, but maybe I can help with some little bits? Your listener to the onFire signal will receive two arguments: the weapon that fired and the bullet that was successfully fired. You could change the bullet's speed in there for the bullet that was just fired. If you need to change all the bullets' anchors no matter what, though, you can say "weapon.bullets.forEach" since "weapon.bullets" is a group. You have both "trackRotation = true" and "fireAngle = 60". That fireAngle is going to be ignored because the weapon is tracking the sprite's rotation. I don't know about the bullet going in the opposite direction. I *suspect* that your tracked sprite isn't pointing the way you think it's pointing, i.e. your graphic is drawn with your sprite facing left but Phaser's angle is set to 0 which is pointing to the right. Just a guess, though. Quote Share this post Link to post Share on other sites
Drewrg 0 Report post Posted November 21, 2016 Thank you for reply, I've rotated the actual png image itself, and that solved the wrong direction of fire. But anyway I still can't adjust speed and anchor of particular bullets. As you can see in gif, the position of weapon is correct, but bullets anchor point is incorrect. Quote Share this post Link to post Share on other sites
LuizOtavio 7 Report post Posted November 22, 2016 hi @Drewrg in Phaser.Weapon.prototype.fire method says: * @return {Phaser.Bullet} The fired bullet if successful, null otherwise. that means you can do: var your_bullet = bullets.fire(); and get Phaser.Bullet sprite that was shoot and change their speed. cheers Quote Share this post Link to post Share on other sites
Drewrg 0 Report post Posted November 25, 2016 Hello @LuizOtavio I used. this.weapon.bullets.setAll('anchor.y', 1); This is worked for me so far. For the bullet speed, I am using Phaser.Physics.arcade.overlap(bulletsGroup, target, function); which is returning the bullet that were collided. Quote Share this post Link to post Share on other sites