So I want to have the player shoot where the cursor is on the screen, I have a global mouse left down event from an online tutorial
I added attack cooldown so it doesn't just keep shooting
I want to make it so the player sprites arms move with the gun thingy, and make the bullets come out of the barrel of the gun. I don't think you can just change the sprite or it would be way too tedious, so I have another armless sprite for when the mouse left click is pressed down, and I have the arms as a seperate object, it basically only has this in step event.
So to spawn the arms I have
But once the arms spawn it doesn't go away, I want them to appear when the player is attacking(holding down left mouse button) only once, and go away once the player stops holding down the button.
Also the bullets desync if the player isn't shooting straight ahead of them, they start spawning out of nowhere. Is there a better way to do this?
So the player presses left mouse click, and the character shoots where the cursor is, their arms pointing the cursor. I also want the sprite to turn around as well as the arms if the cursor is behind the player, so the arm doesn't look like it's bending backwards.
GML:
attack_cooldown +=1;
if(attack_cooldown >=10){
bullet = instance_create_layer(x+33,y+8, "Effect", obj_bullet);
bullet.speed = 13;
bullet.direction= point_direction(x+33,y+8, mouse_x, mouse_y);
bullet.image_angle = bullet.direction;
attack_cooldown = 0;
}
I want to make it so the player sprites arms move with the gun thingy, and make the bullets come out of the barrel of the gun. I don't think you can just change the sprite or it would be way too tedious, so I have another armless sprite for when the mouse left click is pressed down, and I have the arms as a seperate object, it basically only has this in step event.
image_angle = point_direction(x, y, mouse_x, mouse_y);
.So to spawn the arms I have
GML:
if(mouse_check_button(mb_left)){
sprite_index = spr_player_attack;
instance_create_layer(x+24,y+16,"Player", obj_player_arms);
}
Also the bullets desync if the player isn't shooting straight ahead of them, they start spawning out of nowhere. Is there a better way to do this?
So the player presses left mouse click, and the character shoots where the cursor is, their arms pointing the cursor. I also want the sprite to turn around as well as the arms if the cursor is behind the player, so the arm doesn't look like it's bending backwards.