Radius Search Problem
by Richard_H · in Torque Game Engine · 09/08/2006 (8:51 pm) · 5 replies
Hi
I'm having some trouble with this line:
InitContainerRadiusSearch(%this.player.getTransform(), 50,$TypeMasks:: PlayerObjectType);
in the aiPlayer.cs file. I added it so that the bots will look at the nearest person but there seems ot be a problem with that line. Below is the context. Am I missing something?
function AIManager::think(%this)
{
// We could hook into the player's onDestroyed state instead of
// having to "think", but thinking allows us to consider other
// things...
if (!isObject(%this.player))
%this.player = %this.spawn();
InitContainerRadiusSearch(%this.player.getTransform(), 50,$TypeMasks:: PlayerObjectType);
if ((%targetObject = containerSearchNext()) != 0) {
%this.player.aimAt(%targetObject);
}
%this.schedule(500,think);
}
I'm having some trouble with this line:
InitContainerRadiusSearch(%this.player.getTransform(), 50,$TypeMasks:: PlayerObjectType);
in the aiPlayer.cs file. I added it so that the bots will look at the nearest person but there seems ot be a problem with that line. Below is the context. Am I missing something?
function AIManager::think(%this)
{
// We could hook into the player's onDestroyed state instead of
// having to "think", but thinking allows us to consider other
// things...
if (!isObject(%this.player))
%this.player = %this.spawn();
InitContainerRadiusSearch(%this.player.getTransform(), 50,$TypeMasks:: PlayerObjectType);
if ((%targetObject = containerSearchNext()) != 0) {
%this.player.aimAt(%targetObject);
}
%this.schedule(500,think);
}
About the author
#3
function AIManager::think(%this)
{
// We could hook into the player's onDestroyed state instead of
// having to "think", but thinking allows us to consider other
// things...
if (!isObject(%this.player))
%this.player = %this.spawn();
InitContainerRadiusSearch(%this.player.getPosition(),50,$TypeMasks:: PlayerObjectType);
if ((%targetObject = containerSearchNext()) != 0) {
%this.player.aimAt(%targetObject);
}
%this.schedule(500,think);
}
09/09/2006 (3:44 am)
Wait, it's still giving me a syntax error. Same line.function AIManager::think(%this)
{
// We could hook into the player's onDestroyed state instead of
// having to "think", but thinking allows us to consider other
// things...
if (!isObject(%this.player))
%this.player = %this.spawn();
InitContainerRadiusSearch(%this.player.getPosition(),50,$TypeMasks:: PlayerObjectType);
if ((%targetObject = containerSearchNext()) != 0) {
%this.player.aimAt(%targetObject);
}
%this.schedule(500,think);
}
#4
%this.schedule(500, think); is incorrect.
Searching for schedule in your scripts would had shown you that.
Edit: Your TypeMask also has a space in it, which too would had been evident if you had taken a look at already existing examples :) This is good practice if you get a error, and will make you learn faster.
09/09/2006 (4:10 am)
You get the syntax error line in the console.log.%this.schedule(500, think); is incorrect.
Searching for schedule in your scripts would had shown you that.
Edit: Your TypeMask also has a space in it, which too would had been evident if you had taken a look at already existing examples :) This is good practice if you get a error, and will make you learn faster.
#5
P.S. I'm pretty sure the schedule is correct, that code is in the starter.fps by default
09/09/2006 (4:50 am)
I forgot about the console and I think my font was too condensed so I missed the space, thx for the help.P.S. I'm pretty sure the schedule is correct, that code is in the starter.fps by default
Torque 3D Owner Sean H.
InitContainerRadiusSearch(%this.player.getPosition(), 50,.....