G
Garriott
Guest
I am currently programming a run n' gun sidescroller that has single hit and piercing multihit projectiles. For single projectiles, they get destroyed on contact, and multihit ones have a timer on each enemy that resets before being able to be hit by multihit projectiles again, which also doesn't really work completely because there will be two players firing these projectiles on screen and only one can damage at a time doing it the way I am doing it, but it works for the time being.
However, for certain piercing projectiles, I want them to only be able to collide with each enemy only once and then never hit them again despite coming into contact with them again. How would I go about programming something like that?
In addition, I have an arm object set up that snap rotates instantly to where the player is currently aiming when they use the dpad. In this object, I have code for a set point on the object where the bullets come from, and it looks like this.
xx = x + lengthdir_x(20, image_angle );
yy = y + lengthdir_y(20, image_angle );
However, if I use xx and yy as the object spawn point for bullets, they come out of where they're supposed to, but it seems the additional calculation that the game has to do compared to just using plain old x or y makes the bullets come out at the wrong angle when the player rapidly aims up and horizontal.
For example, if the player rapidly aims up and horizontal, sometimes, the bullets will come out of the arm tip while it is aimed upward and they will go horizontally as if the aim was horizontal, but it hasn't gotten there yet, and the same thing happens with aiming upward where the bullets will come out of the tip of the arm while it is horizontal, but they will shoot vertically instead.
Without the xx and yy and just using x and y, the bullets come out properly for each angle, but then they come out of the center of the player rather than the tip of the gun, and that isn't desirable. For some of the bullets I can set the origin point of the sprite to be further away so it looks like they shoot out of the tip of the gun, but that creates problems for some of them rotating because the axis won't be centered.
How can I have the xx and yy code function without the extra delay it seems to add to shooting the bullets?
However, for certain piercing projectiles, I want them to only be able to collide with each enemy only once and then never hit them again despite coming into contact with them again. How would I go about programming something like that?
In addition, I have an arm object set up that snap rotates instantly to where the player is currently aiming when they use the dpad. In this object, I have code for a set point on the object where the bullets come from, and it looks like this.
xx = x + lengthdir_x(20, image_angle );
yy = y + lengthdir_y(20, image_angle );
However, if I use xx and yy as the object spawn point for bullets, they come out of where they're supposed to, but it seems the additional calculation that the game has to do compared to just using plain old x or y makes the bullets come out at the wrong angle when the player rapidly aims up and horizontal.
For example, if the player rapidly aims up and horizontal, sometimes, the bullets will come out of the arm tip while it is aimed upward and they will go horizontally as if the aim was horizontal, but it hasn't gotten there yet, and the same thing happens with aiming upward where the bullets will come out of the tip of the arm while it is horizontal, but they will shoot vertically instead.
Without the xx and yy and just using x and y, the bullets come out properly for each angle, but then they come out of the center of the player rather than the tip of the gun, and that isn't desirable. For some of the bullets I can set the origin point of the sprite to be further away so it looks like they shoot out of the tip of the gun, but that creates problems for some of them rotating because the axis won't be centered.
How can I have the xx and yy code function without the extra delay it seems to add to shooting the bullets?