WasabiHeat
Member
I've been learning GMS with Shaun Spalding's platformer tutorial (big props it's some good stuff) but one thing he did kind of irks me and it's that the bullets fired from the player character's gun are created at the origin of the gun instead of at the tip of it. With the way he coded the game the speed of the bullet moving makes it look like it's coming from the front of the gun, but I intentionally made my bullets slower as I wanted them to arc/have gravity, but that means that it looks like this when I shoot:
(The FPS doesn't do it justice, but notice the white muzzle flash appearing on the gun; it's actually part of the bullet and just the first frame of it's animation)
The code used to rotate the gun is super simple, just:
and the code for creating the bullets is:
As far as i'm concerned I only need to do something to the X & Y parts of the with statement, but i've been scratching my head trying to figure out exactly what to do. Some help would be greatly appreciated!
(The FPS doesn't do it justice, but notice the white muzzle flash appearing on the gun; it's actually part of the bullet and just the first frame of it's animation)
The code used to rotate the gun is super simple, just:
GML:
image_angle = point_direction(x,y,mouse_x,mouse_y);
Code:
with (instance_create_layer(x,y,"Bullets",oBullet)) {
speed = 10;
grv = 0.4;
vsp = 1;
direction = other.image_angle + random_range(-3,3);
image_angle = direction;
}