Game Development Community

ContainerRayCast() Doesn't work on forestItem s - NOT A BUG

by BryceSquared · in Torque 3D Professional · 12/10/2010 (7:03 am) · 1 replies

using this code

function PlayGui::onRightMouseDown(%this, %pos, %start, %ray)
{
   %start = VectorScale(%ray, 2000);
   %end = VectorAdd(%start, %ray);
   
   
   %scanTarg = containerRayCast(%start, %end, $TypeMasks::ForestObjectType);
   
   if (%scanTarg)
      echo(%scanTarg);
}

i couldn't get the raycast to hit the tree.

I stepped through in Torsion and it seemes it doesn't find a ForestObjectType which afaik is the typemask i need to use.

Thanks.

#1
12/10/2010 (8:05 am)
Upon looking more closely at the script i posted... it seems i am actually just an idiot and wrote the wrong code.

function PlayGui::onRightMouseDown(%this, %pos, %start, %ray)  
{  
  %ray = VectorScale(%ray, 2000);  
  %end = VectorAdd(%start, %ray);  
     
     
  %scanTarg = containerRayCast(%start, %end, $TypeMasks::ForestObjectType);        
   if (%scanTarg)  
      echo(%scanTarg);  
}

changing
%start = VectorScale(%ray, 2000);
to
%ray = VectorScale(%ray, 2000);
solves the problem. I probably need to go to bed zzzz.

EDIT: Although that still doesn't do what i want it to do as it doesn't point me to the exact tree that i clicked on. Has anyone done anything like this?