The below code works to a point. Barely anybody gets hit even when 1000s of shots have been fired. An occasional hit will occur, but that is it. It should be occurring much, much more frequently.
`Unit Attacking
For Attack = 2 To (Enemies + 4)
If Object Exist(Attack) = 1
CanFire = Ai Get Entity Can Fire(Attack)
GunOwner = Unit(Attack).Gun
GunAcc = Guns(GunOwner).Accuracy
If CanFire = 1 And Unit(Attack).CanShoot > Guns(GunOwner).Speed
ShotsFired = ShotsFired + 1
`Object Positions
Target = Ai Get Entity Target Id(Attack, 1)
TX# = AI Get Entity Target X(Attack)
TY# = Object Position Y(Target)
TZ# = AI Get Entity Target Z(Attack)
X# = Object Position X(Attack)
Y# = Object Position Y(Attack)
Z# = Object Position Z(Attack)
Position Object Attack + 1000, TX#, 0, TZ#
Point Object Attack + 1000, X#, 0, Z#
`Variables
Unit(Attack).Canshoot = 0
Unit(Attack).StartTime = Timer()
`RayCasting
For Shots = 1 To Guns(GunOwner).Shots
Hit = RayIntersectTypePRO(1, 1, X#, Y#, Z#, TX#, TY#, TZ#)
If Hit = 1
Hits = Hits + 1
HitCount = RayHitCountPro()
For HitNum = 0 To (HitCount - 1)
Object = RayHitObjPRO(HitNum)
Dec Unit(Object).Health, Guns(GunOwner).Damage
Next HitNum
Endif
Next Shots
`Sound
Ai Create Sound X#, Z#, 100, 500
Ai Create Sound Object Position X(Target), Object Position Z(Target), 50, 100
Play Sound Unit(Attack).Gun
Endif
Endif
Next
Can anyone tell me what could possibly be wrong?