K
Kaplutnoir
Guest
Hi, I'm a first time porogrammer, and I'm trying to learn GML. To learn this, I'm trying to program a very simple shooter based loosely on Asteroids. For a few days now, I've been struggling to find a good way to program how to keep a bullet coming out of the barrel of the gun. After some searching on the internet and through some forums, the best one I could find was this:
var inst = instance_create_layer((x + lengthdir_x(50, image_angle)), (y + lengthdir_y(50, image_angle)), "Instances", obj_Shot);
inst.direction = image_angle;
However, it seems I can only adjust the distance from the center point of the sprite, not the exact position at which the bullet is created. So, when I change the center point, I can get the bullet to spawn from the gun's barrel, but the character now has a funny rotation which I don't like at all. The character is holding the gun more to the right of his body, which means I have to adjust the center point to the right as well. I have been looking for code in which I can adjust the "height" of the bullet spawning. But I probably use incorrect wording or phrasing in my searches. Anyone who can help me would earn a lot of my thanks as I've always wanted to learn programming one day and it kinda sucks running into a wall so early in my programming days.
var inst = instance_create_layer((x + lengthdir_x(50, image_angle)), (y + lengthdir_y(50, image_angle)), "Instances", obj_Shot);
inst.direction = image_angle;
However, it seems I can only adjust the distance from the center point of the sprite, not the exact position at which the bullet is created. So, when I change the center point, I can get the bullet to spawn from the gun's barrel, but the character now has a funny rotation which I don't like at all. The character is holding the gun more to the right of his body, which means I have to adjust the center point to the right as well. I have been looking for code in which I can adjust the "height" of the bullet spawning. But I probably use incorrect wording or phrasing in my searches. Anyone who can help me would earn a lot of my thanks as I've always wanted to learn programming one day and it kinda sucks running into a wall so early in my programming days.