GML Help with shooting recoil problem please!

E

Edwin

Guest
I have a variable "can_shoot" that equals to true if I can shoot and to false if not. I also have a variable "shoot_delay" that equals to time (steps) of alarm that makes "can_shoot" variable equal true.

So when I shoot I need to make my bullet object make a "recoil" with changing it's direction.
Code:
with (o_bullet) {
    direction += irandom_range(-shoot_delay, shoot_delay):
}
So it works but when I shooting and have a smaller value of "shoot_delay" variable recoil gets more weaker and weaker, but it's not what I want: I want to make it stronger!.

Video:
How can You see in this video, if "shoot_delay" = 1, then the recoil is smaller than if 'shoot_delay" = 15 or more.

Please help!
 

marasovec

Member
Oh I see. I guess your max shooting delay is 15 so try this
Code:
shoot_delay = 15 - shoot_delay;
direction += irandom_range(-shoot_delay, shoot_delay):
 
E

Edwin

Guest
Oh I see. I guess your max shooting delay is 15 so try this
Code:
shoot_delay = 15 - shoot_delay;
direction += irandom_range(-shoot_delay, shoot_delay):
The problem isn't in it. You see, when I shoot and my shoot_delay is 15 or more, shoot recoil is big, but I want to make it small
 

marasovec

Member
I'm trying to understand.. You have a shoot recoil which depends on the shoot_delay but you want to make the recoil smaller but still depending on the delay?
 
E

Edwin

Guest
I'm trying to understand.. You have a shoot recoil which depends on the shoot_delay but you want to make the recoil smaller but still depending on the delay?
I just need to make it negative. Like the less the shoot delay value then stronger the shoot recoil.
 
S

spoonsinbunnies

Guest
well I think what is happening here is every time you make a bullet your changing the direction of every bullet meaning they eventually even out near the middle of the random. Make sure your only refencing the bullet you create if that's the case by doing something along the lines of

new=instance_create(x,y,o_bullet)
new.direction+= irandom_range(-shoot_delay, shoot_delay):

Also its worth noting if that dosent help for everyone else I believe when he says recoil he means the bullets accuracy.
 
E

Edwin

Guest
well I think what is happening here is every time you make a bullet your changing the direction of every bullet meaning they eventually even out near the middle of the random. Make sure your only refencing the bullet you create if that's the case by doing something along the lines of

new=instance_create(x,y,o_bullet)
new.direction+= irandom_range(-shoot_delay, shoot_delay):

Also its worth noting if that dosent help for everyone else I believe when he says recoil he means the bullets accuracy.
Look! When shoot_delay is equal to a small number, the recoil of the weapon also decreases, and I want the opposite - to increase.
 
S

spoonsinbunnies

Guest
As I mentioned before that's most likely caused by the fact that your changing all the bullets on the fields direction every time you make a bullet not just the new one created.
 
S

spoonsinbunnies

Guest
ok nevermind I see what your doing, as mentioned above best way is to just inverse it by using something like
accuracy=16-shoot delay
direction+=irandom_range(-acccuracy, accuracy):

this means theres a 30 direction spread if the can shoot is 1 and a 1 degree if the shooting speed is 15
 
Top