Skip to main content
Post Closed as "Duplicate" by CommunityBot
Condensed by removing duplication and irrelevant detail.
Source Link
Anko
  • 13.5k
  • 10
  • 56
  • 82

How todo I generate projectiles with the direction oftoward the mouse pointer?

I'm experimenting onmaking a small top-down space shooter where the player controls a ship and he can aim and shoot bullets toward the direction ofusing the mouse cursor. My question is howHow can I shoot the bullets with the angle given by the mouse cursor ?

Currently myfire bullets are created with random "angle values" ranging from -10 to 10 to each the X and Y axis so that way their position values are augmented or diminished each update givingfrom the ship at the illusion that they follow an angle. But that just gives me a bullet that gets shot in a random direction and I need to shoot them in a specific direction (towards the mouse cursor).

I get the feeling I'm missing something here.

Edit : To make things clearer I'm looking for ways to move the projectile alongside an angleangle from the ship to the mouse cursor?

How to generate projectiles with the direction of the mouse pointer

I'm experimenting on a small top-down space shooter where the player controls a ship and he can shoot bullets toward the direction of the mouse cursor. My question is how can I shoot the bullets with the angle given by the mouse cursor ?

Currently my bullets are created with random "angle values" ranging from -10 to 10 to each the X and Y axis so that way their position values are augmented or diminished each update giving the illusion that they follow an angle. But that just gives me a bullet that gets shot in a random direction and I need to shoot them in a specific direction (towards the mouse cursor).

I get the feeling I'm missing something here.

Edit : To make things clearer I'm looking for ways to move the projectile alongside an angle

How do I generate projectiles toward the mouse pointer?

I'm making a top-down space shooter where the player controls a ship and can aim and shoot using the mouse cursor. How can I fire bullets from the ship at the angle from the ship to the mouse cursor?

added 100 characters in body
Source Link
Tristan Dubé
  • 233
  • 1
  • 2
  • 7

I'm experimenting on a small top-down space shooter where the player controls a ship and he can shoot bullets toward the direction of the mouse cursor. My question is how can I shoot the bullets with the angle given by the mouse cursor ?

Currently my bullets are created with random "angle values" ranging from -10 to 10 to each the X and Y axis so that way their position values are augmented or diminished each update giving the illusion that they follow an angle. But that just gives me a bullet that gets shot in a random direction and I need to shoot them in a specific direction (towards the mouse cursor).

I get the feeling I'm missing something here.

Edit : To make things clearer I'm looking for ways to move the projectile alongside an angle

I'm experimenting on a small top-down space shooter where the player controls a ship and he can shoot bullets toward the direction of the mouse cursor. My question is how can I shoot the bullets with the angle given by the mouse cursor ?

Currently my bullets are created with random "angle values" ranging from -10 to 10 to each the X and Y axis so that way their position values are augmented or diminished each update giving the illusion that they follow an angle. But that just gives me a bullet that gets shot in a random direction and I need to shoot them in a specific direction (towards the mouse cursor).

I get the feeling I'm missing something here.

I'm experimenting on a small top-down space shooter where the player controls a ship and he can shoot bullets toward the direction of the mouse cursor. My question is how can I shoot the bullets with the angle given by the mouse cursor ?

Currently my bullets are created with random "angle values" ranging from -10 to 10 to each the X and Y axis so that way their position values are augmented or diminished each update giving the illusion that they follow an angle. But that just gives me a bullet that gets shot in a random direction and I need to shoot them in a specific direction (towards the mouse cursor).

I get the feeling I'm missing something here.

Edit : To make things clearer I'm looking for ways to move the projectile alongside an angle

Tweeted twitter.com/#!/StackGameDev/status/78208231138271232
Source Link
Tristan Dubé
  • 233
  • 1
  • 2
  • 7

How to generate projectiles with the direction of the mouse pointer

I'm experimenting on a small top-down space shooter where the player controls a ship and he can shoot bullets toward the direction of the mouse cursor. My question is how can I shoot the bullets with the angle given by the mouse cursor ?

Currently my bullets are created with random "angle values" ranging from -10 to 10 to each the X and Y axis so that way their position values are augmented or diminished each update giving the illusion that they follow an angle. But that just gives me a bullet that gets shot in a random direction and I need to shoot them in a specific direction (towards the mouse cursor).

I get the feeling I'm missing something here.