Pointers/info on bot-like things...
by Lewis Bruck · in Torque Game Engine · 10/18/2001 (7:52 pm) · 11 replies
I was wondering if anybody had any pointers on how to make server-controlled entities. I've looked at the bot tutorial on http://gameznet.com/v12/scripting/ and got it to work with 1.1 (change ::onAIConnect to ::onConnect) and got a LightMaleHumanArmor Player to spawn. I was even able to get code to echo to console every 5 seconds. However, I wasn't successful in getting it to do any animations. I feel I don't fully understand what a Player is and how it fits together. Do I not have a data structure set up correctly? Is there an initialization function I need to call? Am I misusing the scheduling system? Am I not sending a message correctly? Is there a better way to do this? Am I rambling too much?
This is a code snippet of the function I call after I create the new Player. I get the wave messages every five seconds, but no movement:
function Player::Wave (%this)
{
echo("wave");
%this.playCelAnimation(%this, "wave");
%this.schedule(5 * 1000, "Wave");
}
Does anyone know of any discussions/tutorials of server-side scripting? I don't want to see one more HUD :-)
Thanks.
This is a code snippet of the function I call after I create the new Player. I get the wave messages every five seconds, but no movement:
function Player::Wave (%this)
{
echo("wave");
%this.playCelAnimation(%this, "wave");
%this.schedule(5 * 1000, "Wave");
}
Does anyone know of any discussions/tutorials of server-side scripting? I don't want to see one more HUD :-)
Thanks.
#2
10/19/2001 (9:15 pm)
Thanks! I understand things better now (and my little dude waves). Now off to get him to move about and look at things...
#3
10/23/2001 (10:14 pm)
can the bots run around now?
#4
10/24/2001 (3:42 pm)
The bots do not run around, but they will stand and wave :) Pat Wilson was working some basic bot functionality, but I think he got side-tracked.
#5
I don't know if this is the "correct" way to make a bot move, but this is what I worked out:
After you've created the Player object, call SetControlObject() on the client (AIConnection) object and pass in the newly created player.
In your "think" function (the one that you schedule to run periodically), you can get the client (AIConnection) object by calling %player.GetControllingClient(). You can then set a movement direction using %client.setMove().
I'll try to figure out the current position so I can stop and steer and turn around tonight.
10/24/2001 (7:42 pm)
I was able to get my little dude to run around. OK, just side step, but that should be just a change to the setMove() parameters.I don't know if this is the "correct" way to make a bot move, but this is what I worked out:
After you've created the Player object, call SetControlObject() on the client (AIConnection) object and pass in the newly created player.
In your "think" function (the one that you schedule to run periodically), you can get the client (AIConnection) object by calling %player.GetControllingClient(). You can then set a movement direction using %client.setMove().
I'll try to figure out the current position so I can stop and steer and turn around tonight.
#6
I have my bot retreating from any nearby players (targets) and firing on them. Found the target by doing a containersearch.
Then, faced the target (yaw, at least) by using setTransform. This is probably not the best method, suggestions are welcome :)
Then i used setMove to move him backwards, thus retreating. I threw in a weapon and activated his trigger to make him fire.
Now the only problem I'm having is adjusting the pitch so he'll shoot me and not the ground if I'm above him. If anyone has any clues on this I'd appreciate it.
10/25/2001 (7:45 am)
Yeah, Lewis! I just got mine doing basically the same thing last night, I see you have been working on the same thing.I have my bot retreating from any nearby players (targets) and firing on them. Found the target by doing a containersearch.
Then, faced the target (yaw, at least) by using setTransform. This is probably not the best method, suggestions are welcome :)
Then i used setMove to move him backwards, thus retreating. I threw in a weapon and activated his trigger to make him fire.
Now the only problem I'm having is adjusting the pitch so he'll shoot me and not the ground if I'm above him. If anyone has any clues on this I'd appreciate it.
#7
10/29/2001 (9:33 pm)
How many args is the setMove function supposed to take?
#8
so, setMove("x",0.5) would move him along the x-axis at half speed (i think).
You can also adjust pitch and yaw using this method. I was having problems doing this at first, but I got it worked out.
10/30/2001 (6:38 am)
SetMove takes two arguments, 1) the move and 2) how much. so, setMove("x",0.5) would move him along the x-axis at half speed (i think).
You can also adjust pitch and yaw using this method. I was having problems doing this at first, but I got it worked out.
#9
this is my function that i call like the wave function
function Player::Run (%this)
{
%this.GetControllingClient();
%client.setMove("x", 0.5);
}
can't find %client object .. i also tried %this.setMove() ..but that also doesn't work
where do i get the %player from to call
%player.GetControllingClient() ?
and i'm doing
%client.SetControlObject(%player);
from the AIconnect::onconnect function .. is this also wrong?
thanks for tha help
10/30/2001 (2:22 pm)
i can't quite figure this out.this is my function that i call like the wave function
function Player::Run (%this)
{
%this.GetControllingClient();
%client.setMove("x", 0.5);
}
can't find %client object .. i also tried %this.setMove() ..but that also doesn't work
where do i get the %player from to call
%player.GetControllingClient() ?
and i'm doing
%client.SetControlObject(%player);
from the AIconnect::onconnect function .. is this also wrong?
thanks for tha help
#10
function Player::Run (%this)
{
%client = %this.GetControllingClient();
%client.setMove("x", 0.5);
}
The rest of what you describe looks OK.
10/30/2001 (10:37 pm)
I think all you need to do is add "%client = ":function Player::Run (%this)
{
%client = %this.GetControllingClient();
%client.setMove("x", 0.5);
}
The rest of what you describe looks OK.
#11
i think i'm putting the SetControlObject() in the wrong place ..or maybe passing it the wrong things
where did you guys put SetControlObject() and how did you call it?
thanks
10/31/2001 (10:09 pm)
now it's telling me %client = 0i think i'm putting the SetControlObject() in the wrong place ..or maybe passing it the wrong things
where did you guys put SetControlObject() and how did you call it?
thanks
Torque Owner Tim Gift
function Player::Wave (%this) { echo("wave"); %this.playCelAnimation("wave"); %this.schedule(5 * 1000, "Wave"); }If you use object "." notation, the %this argument is provided automatically. So these to calls are equivilent:playCelAnimation(%this,"wave"); %this.playCelAnimation("wave");