[SOLVED] I want to shoot in 2 sides

C

clyver

Guest
(Sorry for the bad english)
I'm a total newbie in this but, i'm having some issues with my shoot in Game Maker Studios 2.
I want to shoot in two sides, and the Player only shoot in one direction. I can shoot while i'm in the right or in the left, but the bullet only go to the right, no matter what position i'm in.

This is the Gun's Begin Step Event code:

x = OPires.x;
y = OPires.y+10;
image_xscale = OPires.image_xscale;

firingdelay = firingdelay - 1;
if (keyboard_check(ord("Z")) && (firingdelay < 0))
{
firingdelay = 30;
with (instance_create_layer(x,y,"Balas",OTiro))
{
speed = 10;
direction = other.image_xscale;
image_angle = direction;
}
}
Related pic
 
Not sure If I read the code correctly, but I thin you are setting the projectiles angle and direction to the players image_xscale and I'm assuming that's either 1 or -1. But you want to set it to 0 or 180.

So if your player object has a direction of 0 or 180 as well, then I guess something like this:
Code:
direction = other.direction;
if not maybe something like this:
Code:
direction = -90 + 90 * other.image_xscale;
 
C

clyver

Guest
Oh my god, it worked. Thank you so much. I spend so much time and effort in a lot of complicated coding while it was so simple!!
Thank you very much!
 
Top