GML How do I attach my weapon to my character if the model is 3D in a 2D space?

Hello everyone,


I recently replaced the 2D sprite of the gun I was using with a 3D model of a gun and ran into some problems. The 3D model was rendered from one side so that it could mimic a 2D object. Previously the 2D gun sprite was at least close to the character, but now it's pretty far away. In the picture, there is also a 3d model of a crate and when the player attempts to jump onto it, they hover over what can be best described as an invisible wall. Do these problems have anything to do with the fact that the objects are actually 3D models or is this a programming issue. Here is the code inside the gun object that I tried adjusting to fix the problem:

x = Oplayer.x;
y = Oplayer.y+10;

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

firingdelay = firingdelay - 1;
recoil = max(0,recoil - 1);
if (mouse_check_button(mb_left)) and (firingdelay < 0)
{
recoil = 4;
ScreenShake(2,10);
firingdelay= 5;
audio_play_sound(snShot,5,false);
with (instance_create_layer (x,y,"Bullets",Obullet))
{
spd = 25;
direction = other.image_angle +random_range(-3,3);
image_angle = direction;
}

}

x = x - lengthdir_x(recoil, image_angle);
y = y - lengthdir_y(recoil, image_angle);

if (image_angle > 90) and (image_angle < 270)
{
image_yscale = -1;
}

else
{
image_yscale = 1;
}


Any help with this problem would be greatly appreciated.

Thanks.
 

Attachments

Top