S
Scytaic
Guest
Hi, I'm completely new to GMS2 and GML/coding. I've been following Shaun's platform tutorial and managed to change the code a bit so the bullets only shoot in the direction the character is facing (because I don't want my game to use the mouse). I found that specific part of the code online and don't understand it that well to be honest. But I managed to make it so the bullets shoot to the right but they still continue to shoot to the right even when the character is facing left. This is the script I'm using for the gun:
If I change any of the if object2.x > x (swap the <'s over etc) it'll then only shoot to the left. How do I make it so it only shoots right if facing right and only shoots left if facing left? Sorry, I'm a complete n00b haha. Thanks in advance!
Code:
x = object2.x;
y = object2.y;
if object2.x > x
{
if direction = !90
{
image_angle = direction
}
} else
if object2.x < x
{
if direction = !90
{
image_angle = direction+180
}
}
firingdelay = firingdelay - 1;
if (keyboard_check_pressed(ord("Z"))) && (firingdelay < 0)
{
firingdelay = 5;
with (instance_create_layer(x,y,"bullets",obullet))
{
speed = 10;
direction = other.image_angle + random_range(-3,3);
image_angle = direction;
}
}
Last edited by a moderator: