Calculate initial bullet speed based on player's current angle and velocity

0 favourites
  • 3 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • So take the asteroids template for example. In that template the bullet speed is the same regardless of the player ship current speed/moving angle, but how could one take into account the current moving angle of the player to adjust the bullet to fire more realistically?

  • You would want to do some vector addition - The original speed and angle of the bullet added to the speed and angle of the player. The most straightforward way would be to take the x and y velocities separately and just add them to their respective velocities. Unfortunately the bullet behavior doesn't have access to individual velocities on each axis.

    The neat thing is you can have multiple bullet behaviors on the same object. So add a second bullet behavior to the bullet object, and set the angle and speed of the second bullet behavior to the angle and speed of the player object. Assuming you're using custom movement like in the example, it would look like so:

    -> Bullet: Set Bullet2 angle of motion to Player.CustomMovement.MovingAngle degrees
    -> Bullet: Set Bullet2 speed to Player.CustomMovement.Speed
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • that's a creative solution, seems to work. Thanks oosyrag

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)