Game Development Community

anyone have Click RPG style movement tutorial?

by Enel · in Torque 3D Professional · 02/03/2010 (4:10 am) · 3 replies

i have make like this..

function serverCmdTarget(%client, %mouseVec, %cameraPoint)
{   
   echo("pos: ", %cameraPoint);   
   echo("vec: ", %mouseVec);
      
   //Determine how far should the picking ray extend into the world?   
   %selectRange = 200;   
  
   // scale mouseVec to the range the player is able to select with mouse   
   %mouseScaled = VectorScale(%mouseVec, %selectRange);   
      
   // cameraPoint = the world position of the camera   
   // rangeEnd = camera point + length of selectable range   
   %rangeEnd = VectorAdd(%cameraPoint, %mouseScaled);   
   %FirstSearchMask = $TypeMasks::InteriorObjectType;   
   %SecondSearchMask = $TypeMasks::TerrainObjectType;   
      
   // Search for objects within the range that fit the masks above. If we are   
   // in first person mode, we make sure player is not selectable by setting   
   // fourth parameter (exempt from collisions) when calling ContainerRayCast   
   $obstruction = ContainerRayCast (%cameraPoint, %rangeEnd, %FirstSearchMask);   

   // if we didn't get interior, then try terrain   
   if(!$obstruction)   
   {   
      //%scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %SecondSearchMask);   
      %scanTarg = ContainerRayCast (%cameraPoint, %rangeEnd, %SecondSearchMask);
   }   
      
   // a target in range was found so select it   
  
   if (%scanTarg)   
   {   
      %targetObject = getWords(%scanTarg,1,3);

      %client.player.setMoveDestination(%targetObject);   
   }
}

but it isnt work when i control Player character..

anyone have rpgstyle movement tutorial?..

#1
02/03/2010 (5:25 am)
you can refer to here
http://docs.torquepowered.com/torque-3d/official/
and looking for RTS prototype.
#2
02/03/2010 (9:05 am)
The trick is to *not* assign controls to the AiPlayer. Setup a camera in orbit mode around the player and make the camera the control object. Then you can use setMoveDestination().
#3
02/03/2010 (7:46 pm)
Thx all!