EntityDistance#
Blitz3D Forums/Blitz3D Beginners Area/EntityDistance#
| ||
whats the best way to use this function to cut down on collision checks? say on bullets in a shooter |
| ||
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. |
| ||
thanks mate my shooter i made a while back was very slow im going back now to see if i can speed it up |
| ||
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. |
| ||
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. |