How to make bullet shoot from the barrel in gamemaker 2[SOLVED]

1.1k views Asked by At

when i shoot bullets with offset(when shooting the bullet would spawn as if the gun is straigh forward even if I have lets say aimed it upwards)

the gun origin point

the offset doesnt take gun rotation into the account.

The video of the problem: https://i.stack.imgur.com/Ur24u.jpg.

Heres the gun/shooting code:

x = oPlayer.x + 30;
y = oPlayer.y;

image_angle=point_direction(x,y,mouse_x,mouse_y);

firerate -= 1;
if mouse_check_button_pressed(mb_left)
{
    with(instance_create_layer(x + lengthdir_x(50,image_angle) ,y ,"Bullets",oBullet))
    {
        speed = 20;
        direction = other.image_angle;
        image_angle = direction;
    }

}         

Thanks in advance!

[SOLUTION]

edit: after 3 more hours of search I found the solution:

Spawn bullet at barrel of gun

0

There are 0 answers