Game Development Community

AIWheeledVehicle / Schedule Problem

by Chris "DiGi" Timberlake · in Torque Game Engine · 09/22/2005 (6:57 pm) · 6 replies

Ok, so I got the AI Wheeled Vehicle in 1.4 working. Through pain I might add, spent hours finding an issue and it was i didn't declare a varible =\.

At any rate, i'm trying to get the vehicle to detect if theres a interior ahead of it, about every 1/2 second. However, when I use the code below, it prints it over 100 times in less then a second, and crashes the engine.

function AIWheeledVehicle::CheckInterior(%this)
{
  // %player = %client.player;
   %eye = %this.getEyeVector();
   %vec = vectorScale(%eye, 200);
   %startPoint = %this.getEyeTransform();
   %endPoint = VectorAdd(%startPoint,%vec);

   %searchMasks = $TypeMasks::InteriorObjectType;
   
   %object = ContainerRayCast (%startPoint, %endPoint, %searchMasks, %this);
   
   if(%object)
   {
      echo("INTERIOR ALERT (INSERT AVOIDENCE CODE HERE)");  
      %this.stop();    
   }
   else{
      echo("NO INTERIOR!");
      $foo = schedule(1 * 1000,0,%this.checkinterior());
      cancel($foo);
   }
}

Any ideas?

#1
09/22/2005 (7:00 pm)
Update: I removed the echo("NO INTERIOR"); and this is what i got

==>1489.checkinterior();
INTERIOR ALERT (INSERT AVOIDENCE CODE HERE)
==>1489.checkinterior();
base/server/scripts/AI/aiCore.cs (158): ::containerRayCast - wrong number of arguments.
base/server/scripts/AI/aiCore.cs (158): usage: ( Point3F start, Point3F end, bitset mask, SceneObject exempt=NULL )Cast a ray from start to end, checking for collision against items matching mask.

If exempt is specified, then it is temporarily excluded from collision checks (For instance, you might want to exclude the player if said player was firing a weapon.)
@returns A string containing either null, if nothing was struck, or these fields:
            - The ID of the object that was struck.
            - The x, y, z position that it was struck.
            - The x, y, z of the normal of the face that was struck.
base/server/scripts/AI/aiCore.cs (158): ::containerRayCast - wrong number of arguments.
base/server/scripts/AI/aiCore.cs (158): usage: ( Point3F start, Point3F end, bitset mask, SceneObject exempt=NULL )Cast a ray from start to end, checking for collision against items matching mask.

If exempt is specified, then it is temporarily excluded from collision checks (For instance, you might want to exclude the player if said player was firing a weapon.)
@returns A string containing either null, if nothing was struck, or these fields:
            - The ID of the object that was struck.
            - The x, y, z position that it was struck.
            - The x, y, z of the normal of the face that was struck.
base/server/scripts/AI/aiCore.cs (158): ::containerRayCast - wrong number of arguments.
base/server/scripts/AI/aiCore.cs (158): usage: ( Point3F start, Point3F end, bitset mask, SceneObject exempt=NULL )Cast a ray from start to end, checking for collision against items matching mask.

If exempt is specified, then it is temporarily excluded from collision checks (For instance, you might want to exclude the player if said player was firing a weapon.)
@returns A string containing either null, if nothing was struck, or these fields:
            - The ID of the object that was struck.
            - The x, y, z position that it was struck.

As you can see, at first it worked fine.
#2
09/23/2005 (11:38 am)
It could be something to do with these repeated errors:

base/server/scripts/AI/aiCore.cs (158): ::containerRayCast - wrong number of argument
s.
base/server/scripts/AI/aiCore.cs (158): usage: ( Point3F start, Point3F end, bitset m
ask, SceneObject exempt=NULL )Cast a ray from start to end, checking for collision ag
ainst items matching mask.

Take a look and check the arguments.


Matthew Grint
#3
09/23/2005 (3:08 pm)
I think its being called too fast and it messes up, because the first time i called it, when it was aimed at a building and wasn't set to reschedule, it worked. Thnx tho. Anyone have any ideas?
#4
09/23/2005 (3:26 pm)
I think Matt is right, but the key is that when it's called from schedule some of your parameters may turn out to be blank. For example, have you double checked to make sure "%this" is correct when called from schedule?
#5
09/23/2005 (4:17 pm)
Chris, I believe it should be like this:

%this.schedule(1 * 1000,"checkinterior");
#6
09/23/2005 (7:05 pm)
Ok, thnx guys i'll try it!