I created a new method for calculating hit/miss shots for shooter type maps a while back. Simply, I compare the players camera angle with the angle between two points. The two points being the player controlled unit and the point of the potential target unit. If these angles are approximately the same, you are aiming in the direction of the target unit.
I wrote my method as galaxy script code, but I will walk you through the concepts.
First, I have a region which is always centered on my player ControlledUnitt.
When units enter the region, they are added to a player group of Targets.
When they leave or die, they are removed.
Next, when the player shoots, my "AngleMatch" function cycles through all of the units in this region that have been added to the group Targets.
It checks compares the CameraYaw with the value of the angle between two points (position of ControlledUnit, position of TargetUnit). If they match, just verify height.
That is the jist of the concept.
Advantages: Much faster execution than traceline.
Disadvantages: Collision detection : if no other methods are added, you can simply shoot through walls.
Color me impressed, this is really nice. It doesn't solve the b-net lag problems but its so clever and full of smartness (worst way of putting it)! I applaude your creativity sir.
Should use the angle of tangent with the radius of the target and the distance of the player unit to target for a more accuarcy feeling system. Thats what I did.
had to check each point between my target with increments and check the height of the ground and see if it blocks the path of the bullet. So that a hill in front of me I can't shoot thur it. Yours seems like you can shoot thur hills. Then I used regions to check if the point is within region and whether path of the bullet is higher or lower of the custom value i placed for that region.
If you want it to go EVEN faster, don't use the distance between points function. That uses square roots, but for this problem, there is no need. Since you are COMPARING distances, rather than printing them out, you can simply compare a^2 vs b^2 rather than a vs. b. This saves you from using a costly square root operation. Just make your own squareDist function that returns the distance squared.
I need the distance to scale my angle. For example, the valid angle bounds is wide when the points are close together, and slim when far apart. I use the distance to calculate the valid angle bounds using trig...if I can do this with squaredDist lmk
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I created a new method for calculating hit/miss shots for shooter type maps a while back. Simply, I compare the players camera angle with the angle between two points. The two points being the player controlled unit and the point of the potential target unit. If these angles are approximately the same, you are aiming in the direction of the target unit.
I wrote my method as galaxy script code, but I will walk you through the concepts.
First, I have a region which is always centered on my player ControlledUnitt. When units enter the region, they are added to a player group of Targets. When they leave or die, they are removed.
Next, when the player shoots, my "AngleMatch" function cycles through all of the units in this region that have been added to the group Targets. It checks compares the CameraYaw with the value of the angle between two points (position of ControlledUnit, position of TargetUnit). If they match, just verify height.
That is the jist of the concept.
Advantages: Much faster execution than traceline.
Disadvantages: Collision detection : if no other methods are added, you can simply shoot through walls.
Color me impressed, this is really nice. It doesn't solve the b-net lag problems but its so clever and full of smartness (worst way of putting it)! I applaude your creativity sir.
@AnOddRadish: Go
flattering,
you can test it on my map
search SlayerCraft on bnet, kill zombies have fun
@RedFromWinter: Go
Should use the angle of tangent with the radius of the target and the distance of the player unit to target for a more accuarcy feeling system. Thats what I did.
@gamfvr: Go
I did that "scaledAngle=ATan2(0.5, distance);" assuming 0.5 being my targets radius
:)
How did you check line of sight/collision detection?
@RedFromWinter: Go
had to check each point between my target with increments and check the height of the ground and see if it blocks the path of the bullet. So that a hill in front of me I can't shoot thur it. Yours seems like you can shoot thur hills. Then I used regions to check if the point is within region and whether path of the bullet is higher or lower of the custom value i placed for that region.
If you want it to go EVEN faster, don't use the distance between points function. That uses square roots, but for this problem, there is no need. Since you are COMPARING distances, rather than printing them out, you can simply compare a^2 vs b^2 rather than a vs. b. This saves you from using a costly square root operation. Just make your own squareDist function that returns the distance squared.
@LazyCoder: Go
I need the distance to scale my angle. For example, the valid angle bounds is wide when the points are close together, and slim when far apart. I use the distance to calculate the valid angle bounds using trig...if I can do this with squaredDist lmk