TheOnlyWRT
Member
Hello!
I have a top-down shooter where the player shoots towards the mouse with both the player and bullet sprite rotating towards the mouse. However, I am trying to get the bullet to spawn at the tip of the gun on the player's sprite, but I am having a real hard time doing that. The code I currently have is:
The specs of the sprite are given below (the white dot off the tip of the gun is where I would like the bullet to spawn). The sprite's anchor is set to the middle center:
The position (74,49) is where the white dot is relative to the top left corner of the sprite.
And an in-game image of the issue (shows how the bullets are spawning way off currently):
Thanks in advance for the help!
I have a top-down shooter where the player shoots towards the mouse with both the player and bullet sprite rotating towards the mouse. However, I am trying to get the bullet to spawn at the tip of the gun on the player's sprite, but I am having a real hard time doing that. The code I currently have is:
GML:
//create the bullet
var bulletX = x - lengthdir_x(80, mouse_x);
var bulletY = y + lengthdir_y(60, mouse_y);
with (instance_create_layer(bulletX, bulletY, "Player", objectBullet)) {
//bullet code in here is not important
}
The position (74,49) is where the white dot is relative to the top left corner of the sprite.
And an in-game image of the issue (shows how the bullets are spawning way off currently):
Thanks in advance for the help!