Weapon Heat Variable (Spray Pattern / Spread)
0xE69 opened this issue ยท 0 comments
Weapon spray pattern needs to be more of a V or Diamond Shape so that it starts at the bottom of the V, As you shoot the weapon goes up and the accuracy goes down. https://youtu.be/-z0gDmojzHM?t=88
Each weapon should have a heat variable. This variable starts at 0 and increases every time the weapon is fired. Over time, this variable should decrease gradually back toward 0, simulating the weapon cooling down.
You'll need to pick a non-random function that will determine the radius (r) and angle (theta, t) of the bullet spread based on the current heat (h) of the weapon. This function defines the shape of your spray pattern (V or diamond). For simplicity, let's start with a basic V-shaped pattern.
We need a heat veriable for weapons.
protected float heat = 0.0F;
protected final float heatIncreasePerShot = 1.0F; // Adjust as needed
protected final float heatDecreasePerTick = 0.05F; // Adjust as needed
Whenever the gun fires, increase the heat variable. This could be done in the handleShoot method or wherever the gun's shooting logic is implemented.
In the handleTick method, gradually decrease the heat over time to simulate cooling down.
Create a method to calculate the bullet spread (radius r and angle theta) based on the current heat. For a simple V-shaped pattern, you might increase the spread linearly with heat and alternate the angle to spread shots left and right as heat increases.
When handling a shot in handleShoot, use the bullet spread calculations to adjust the bullet's trajectory.
We need to be able to adjust the heat increase per shot, the heat decrease per tick, and the bullet spread calculation.