November 25, 2020, 07:45:42 AM

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

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
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
  10.         PointEntity piv,entity2:MoveEntity piv,0,0,rad#:FreeEntity entity2
  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
  25. Function SphereLaps(x1#,y1#,z1#,rad1,x2#,y2#,z2#,rad2)
  26.         dis#=Sqr((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1))
  27.         If dis#<=rad1+rad2 Return True Else Return False
  28. End Function
  29. ;
  30. ;
  31. ;
  32. Function entitylaps(entity1,rad1,entity2,rad2)
  33.         If Abs(EntityDistance(entity1,entity2))<=(rad1+rad2) Return True Else Return False
  34. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal