November 25, 2020, 07:45:42 AM

Author Topic: [bb] EntitySphere elapsing box check by aab [ 1+ years ago ]  (Read 586 times)

BlitzBot

• Jr. Member
• Posts: 1
[bb] EntitySphere elapsing box check by aab [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : EntitySphere elapsing box check
Author : aab
Posted : 1+ years ago

Description : dont look at me like that! i know, uber simple but i put it up anyway... still usefull

Code :
Code: BlitzBasic
1. Function entCubeLaps(entity1,rad#,ax#,ay#,az#,havwidth#,havlen#=0,havheight#=0);checks sphere for intersection with cube
2.
3.         If Not havlen havlen=havwidth
4.         If Not havheight havheight=havwidth
5.
6.
7.         Local piv%=CreatePivot():PositionEntity piv,EntityX(entity1),EntityY(entity1),EntityZ(entity1)
8.         ;point it towrads 'box', and move it towards it by the suggested Radius
9.         entity2=CreatePivot():PositionEntity entity2,ax,ay,az
11.
12.         Local bx#=EntityX(piv),by#=EntityY(piv),bz#=EntityZ(piv)
13.
14.         FreeEntity piv
15.
16.         ;final condition
17.         If (bx>=ax-havwidth# And bx=<ax+havwidth#) And (by>=ay-havheight# And by<=ay+havheight#) And (bz>=az-havlen# And bz<=az+havlen#) Return True
18.
19.
20.         Return False
21. End Function
22. ;
23. ;
24. ;some other crappy things
26.         dis#=Sqr((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1))
28. End Function
29. ;
30. ;
31. ;