EntityDistance#

Blitz3D Forums/Blitz3D Beginners Area/EntityDistance#

Pete Carter(Posted 2007) [#1]
whats the best way to use this function to cut down on collision checks? say on bullets in a shooter


Terry B.(Posted 2007) [#2]
 
Dis# = Entitydistance(Entity1,entity2)
If dis# < collisiondis ; if the distance away is less then amount you want it to check for.
collision = true ;do whatever you want them to do if they collide
Endif 


Just get the distance between the two entitys and check it against the max distance you want them to still make a collision from.


Pete Carter(Posted 2007) [#3]
thanks mate my shooter i made a while back was very slow im going back now to see if i can speed it up


GfK(Posted 2007) [#4]
Since its theoretically possible for a bullet to pass through its target entity by doing it this way, you should also employ a check to make sure that hasn't happened.

One way you could do this, use DeltaPitch() and/or DeltaYaw() on the bullet. If either or both of them return a value less than -90, or greater than 90, then the target object is behind the bullet and a collision should have been triggered.


Dreamora(Posted 2007) [#5]
its easier to disable collision at all and use linepick with bullet radius and xyz = current pos and dx,dy,dz = movement vector

this normally is a very fast and minimal check and prevents "port through" issues at all.