0 Favourites

How do I move bullets

  • Quick question

    I have a player object that moves and rotates (space ship behavior). When the object is moving and then rotates and fires while moving how do i get the bullets movement to match the player objects movement?

    In the example picture below

    The player is moving to the right as shown by the red arrow

    The player has rotated to the left to fire. When it fires its bullet it follows the green line

    How do i get the bullet to fire along the blue line (gaining the same directional movement(red arrow) as the player)

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Well, if you set the bullets and the spaceship facing the same direction on their original sprites, i think you can then set the projectile angle to the player's angle every time you create one. If you are already doing that and the behavior is still weird like you are describing maybe you should upload part of your code, or even better a capx. so we can take a better look on what's going on.

    Now, for the bullet to gain the same directional movement as the player. You could try and add some X and Y variables inside the bullet object and set them to zero, and then change them to specific values depending on the keys the player is pressing. And while they are on the screen you change their X and Y position values every tick. So for instance, the player is pressing to the right, the X would be 5 and the Y 0 so every tick the bullets fired would move to the right.... This might work weird depends how the ship moves, but I suggest you to start from there and improve it later.

    Hope it helps o/

  • Set this up quick

    Move with w,s,a,d and shoot with space.

  • found this but unfortunately the capx is broken

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