PDA

View Full Version : Universal Class AIController - many bots



SeBeQ
04-22-2010, 08:06 AM
Hi everyone!

I created a script based on the forum topic "Creating Custom AI Question" http://forums.epicgames.com/showthread.php?t=718104

I would like to operate a class is not only one bot, and many of the bots.


var Badguy1 MyBadguy1Pawn;

change to


var class<Pawn> MyBadguy1Pawn;

and


function SetPawn(Badguy1 NewPawn)
{
MyBadguy1Pawn = NewPawn;
Possess(MyBadguy1Pawn, false);
MyNavigationPoints = MyBadguy1Pawn.MyNavigationPoints;
}

to


function SetPawn(class<Pawn> NewPawn)
{
MyBadguy1Pawn = NewPawn;
Possess(MyBadguy1Pawn, false);
MyNavigationPoints = MyBadguy1Pawn.MyNavigationPoints;
}

However, this causes confusion:

MyBadguy1Pawn.SetAttacking(false);
C:\UDK\UDK-2010-03\Development\Src\TestGame\Classes\TestEnemyContr oller.uc(82) : Error, Unrecognized member 'SetAttacking' in class 'Class'


another problem is that the function:



var TestEnemyController MyController;

simulated function PostBeginPlay()
{
super.PostBeginPlay();
SetPhysics(PHYS_Walking);
if (MyController == none)
{
MyController = Spawn(class'TestEnemyController', self);
MyController.SetPawn(self);
}

}

Only when I do a class on the basis of whether UTPawn or Pawn and variable swap controller = class'TestEnemyController' bots react properly.

And how to use multiple AIController to many bots?
When I have no change in the controller it comes up with the bot AI deathmatch.

SeBeQ
04-22-2010, 04:30 PM
Problem is here:



TestEnemyController.uc

function SetPawn(class<Pawn> NewPawn)
{
MyBadguy1Pawn = NewPawn;
Possess(MyBadguy1Pawn, false);
MyNavigationPoints = MyBadguy1Pawn.MyNavigationPoints;
}


TestEnemy.uc

MyController.SetPawn(self);


Types do not match

Someone knows how to be converted?

SeBeQ
04-23-2010, 06:00 AM
I asked a difficult question whether or not clear, I can give more details. I do not like to write to myself.

If it is impossible that conversion does anyone know how to send a variable of type object (actor), who is a extend of the object variable (actor)?

I tried to do it myself but have not found a solution.

Contagion
04-23-2010, 01:37 PM
when you do var class<Pawn> MyBadguy1Pawn;

You are instructing that you will be placing a class version not an actual Pawn. So you can't set a class to a Pawn. If you want to create multiple bots just spawn more than one.

Blade[UG]
04-23-2010, 02:04 PM
you can't "convert" a class to an instance of a class. Do you even understand why you tried to change what you tried to change there?


If you want multiple things controlled by a group AI, you're going to have to write a -lot- of code to do so with the Pawn/Controller system, or use the Crowd system.

SeBeQ
04-23-2010, 02:19 PM
Thanks for the reply! I had such a small hope that can be converted into, or by a method to get to the appropriate variable.

Thanks again!

Blade[UG]
04-23-2010, 02:25 PM
You don't seem to understand what the "appropriate variable" is in this case -- the changes that you made to the code there, don't make sense. I can't follow why you would've made those changes to it, because it doesn't look like you're actually trying to do anything different, other than change the variable types to non-compatible things.

SeBeQ
04-23-2010, 02:28 PM
And anyone know why this feature does not work when I have not set a variable Controller?
When I have my MyController should work.



another problem is that the function:

Quote:
var TestEnemyController MyController;

simulated function PostBeginPlay()
{
super.PostBeginPlay();
SetPhysics(PHYS_Walking);
if (MyController == none)
{
MyController = Spawn(class'TestEnemyController', self);
MyController.SetPawn(self);
}

}
Only when I do a class on the basis of whether UTPawn or Pawn and variable swap controller = class'TestEnemyController' bots react properly.

SeBeQ
04-23-2010, 02:38 PM
I did not understand until the end what really keeps' var class<Actor> newVariable, thanks for the explanation.

In my case, I thought (I only thought) to myself that with this variable I get to the class enemy. In that case, I do not know what was really shows 'self'.

Blade[UG]
04-23-2010, 06:19 PM
Pawn and controller already have logic to automatically spawn and connect with each other. You should probably investigate that, instead of trying to re-do it yourself ..