Difference between revisions of "TMap.RayCastVector"

From Soldat Community Wiki
Jump to: navigation, search
(new page)
 
m (Example)
 
Line 26: Line 26:
 
   v2.Y := Random(-100,100);
 
   v2.Y := Random(-100,100);
  
   if RayCast(v1,v2,FALSE,FALSE,FALSE,FALSE,0) then
+
   if RayCastVector(v1,v2,FALSE,FALSE,FALSE,FALSE,0) then
 
     WriteLn('No Vision')  
 
     WriteLn('No Vision')  
 
   else
 
   else

Latest revision as of 18:57, 22 August 2013

function RayCastVector(A, B: TVector; Player, Flag, Bullet, CheckCollider: Boolean; Team: Byte): Boolean
 A: Coordinates of a starting point
 B: Coordinates of another point
 Player: if TRUE, Player collide polygons will be checked
 Flag: if TRUE, Flag collide polygons will be checked
 Bullet: if TRUE, Bullet collide polygons will be checked
 CheckCollider: if TRUE, colliders will be checked
 Team: if Player or Flag are TRUE, Team defines which team colliders are checked
 Result: FALSE if there are no colliders between the points, TRUE if there are

Description

This function will check whether there are colliders between two coordinates on the map.
It's equivalent to RayCast, although it takes TVectors as arguments.

Example

Please check RayCast for more complex example as the differences are trivial.

var
  v1,v2: TVector;

begin
  v1.X := Random(-100,100);
  v1.Y := Random(-100,100);
  v2.X := Random(-100,100);
  v2.Y := Random(-100,100);

  if RayCastVector(v1,v2,FALSE,FALSE,FALSE,FALSE,0) then
    WriteLn('No Vision') 
  else
    WriteLn("Vision');
end.