UDK game Prisoners/Guards
Posted
by
RR_1990
on Game Development
See other posts from Game Development
or by RR_1990
Published on 2012-01-12T11:08:28Z
Indexed on
2012/09/11
21:50 UTC
Read the original article
Hit count: 410
For school I need to make a little game with UDK, the concept of the game is:
The player is the headguard, he will have some other guard (bots) who will follow him. Between the other guards and the player are some prisoners who need to evade the other guards.
It needs to look like this
My idea was to let the guard bots follow the player at a certain distance and let the prisoners bots in the middle try to evade the guard bots. Now is the problem i'm new to Unreal Script and the school doesn't support me that well.
Untill now I have only was able to make the guard bots follow me. I hope you guys can help me or make me something that will make this game work.
Here is the class i'm using to let te bots follow me:
class ChaseControllerAI extends AIController;
var Pawn player;
var float minimalDistance;
var float speed;
var float distanceToPlayer;
var vector selfToPlayer;
auto state Idle
{
function BeginState(Name PreviousStateName)
{
Super.BeginState(PreviousStateName);
}
event SeePlayer(Pawn p)
{
player = p;
GotoState('Chase');
}
Begin:
player = none;
self.Pawn.Velocity.x = 0.0;
self.Pawn.Velocity.Y = 0.0;
self.Pawn.Velocity.Z = 0.0;
}
state Chase
{
function BeginState(Name PreviousStateName)
{
Super.BeginState(PreviousStateName);
}
event PlayerOutOfReach()
{
`Log("ChaseControllerAI CHASE Player out of reach.");
GotoState('Idle');
}
// class ChaseController extends AIController; CONTINUED
// State Chase (continued)
event Tick(float deltaTime)
{
`Log("ChaseControllerAI in Event Tick.");
selfToPlayer = self.player.Location - self.Pawn.Location;
distanceToPlayer = Abs(VSize(selfToPlayer));
if (distanceToPlayer > minimalDistance)
{
PlayerOutOfReach();
}
else
{
self.Pawn.Velocity = Normal(selfToPlayer) * speed;
//self.Pawn.Acceleration = Normal(selfToPlayer) * speed;
self.Pawn.SetRotation(rotator(selfToPlayer));
self.Pawn.Move(self.Pawn.Velocity*0.001); // or *deltaTime
}
}
Begin:
`Log("Current state Chase:Begin: " @GetStateName()@"");
}
defaultproperties
{
bAdjustFromWalls=true;
bIsPlayer= true;
minimalDistance = 1024; //org 1024
speed = 500;
}
© Game Development or respective owner