Shooting matching the way my character is facing.

Hugzgoofy

  • Posts: 3
How do i shoot in the direction my character is facing in a 2D platformer.

merrak

  • *
  • Posts: 2232
How do i shoot in the direction my character is facing in a 2D platformer.

That depends on how you're keeping track of whether the player is facing left or right.

Adder

  • Posts: 35
If you use the mouse to control the direction your character is facing and shoot when clicked, then:

When mouse pressed
if [x of mouse] > [x of Self]
[set animation to Right] (or RightShooting if you have a separate animation for shooting while facing right)
create actortype Playerbullet at [x of self] [y of self] at [Back]
if [x of mouse] < [x of Self]
[set animation to Left] (or LeftShooting if you have a separate animation for shooting while facing right)
create actortype Playerbullet at [x of self] [y of self] at [Back]

and set the velocity and direction of the bullet accordingly.
Hope this helped.
Hiss hiss