ey up
i was just messing around with ai stuff and quickly came up with this, its a very simple zombie type thing. if you can make use of it feel free.
it will just stand there untill it sees the player, then it will follow, making no allowance for obsacles, all it can see is the players tasty brains.
no need for pathnodes or navmesh as it moves directly to the player location.
the code as it is now it takes health away from the player on contact, health goes no lower than 1.
here are some examples of other things you can do to the player pawn.
replace the line P.Health --;
with 1 or more of the following (assuming your player pawn is extended from UTPawn)
P.CustomTimeDilation = 0.1; //slows down time
P.Destroy(); //kills the player
P.DoJump(true);
P.Gasp();
P.GroundSpeed *=2; //double walking speed
P.InitRagdoll();
P.SetDrawScale(0.5); //half size
P.SetPhysics(PHYS_Flying); //make me fly
P.SetPhysics(PHYS_Spider); // i can climb walls!
P.ForceCrouch();
if you have question please ask on this thread
more than likely someone can give you a better answer than i can.
have fun getting them stuck places.
TestZombiePawn.uc
TestZombieBot.uc
Other AI's from me
http://forums.epicgames.com/showthread.php?t=801590
http://forums.epicgames.com/showthread.php?t=799268
http://forums.epicgames.com/showthread.php?t=798718
September Update:
the bot works fine still
i was just messing around with ai stuff and quickly came up with this, its a very simple zombie type thing. if you can make use of it feel free.
it will just stand there untill it sees the player, then it will follow, making no allowance for obsacles, all it can see is the players tasty brains.
no need for pathnodes or navmesh as it moves directly to the player location.
the code as it is now it takes health away from the player on contact, health goes no lower than 1.
here are some examples of other things you can do to the player pawn.
replace the line P.Health --;
with 1 or more of the following (assuming your player pawn is extended from UTPawn)
P.CustomTimeDilation = 0.1; //slows down time
P.Destroy(); //kills the player
P.DoJump(true);
P.Gasp();
P.GroundSpeed *=2; //double walking speed
P.InitRagdoll();
P.SetDrawScale(0.5); //half size
P.SetPhysics(PHYS_Flying); //make me fly
P.SetPhysics(PHYS_Spider); // i can climb walls!
P.ForceCrouch();
if you have question please ask on this thread
more than likely someone can give you a better answer than i can.
have fun getting them stuck places.
TestZombiePawn.uc
Code:
class TestZombiePawn extends UTPawn Placeable; var Pawn P; // variable to hold the pawn we bump into // members for the custom mesh var SkeletalMesh defaultMesh; var MaterialInterface defaultMaterial0; var AnimTree defaultAnimTree; var array<AnimSet> defaultAnimSet; var AnimNodeSequence defaultAnimSeq; var PhysicsAsset defaultPhysicsAsset; simulated function SetCharacterClassFromInfo(class<UTFamilyInfo> Info) { Mesh.SetSkeletalMesh(defaultMesh); Mesh.SetMaterial(0,defaultMaterial0); Mesh.SetPhysicsAsset(defaultPhysicsAsset); Mesh.AnimSets=defaultAnimSet; Mesh.SetAnimTreeTemplate(defaultAnimTree); } simulated event Bump( Actor Other, PrimitiveComponent OtherComp, Vector HitNormal ) { `Log("Bump"); Super.Bump( Other, OtherComp, HitNormal ); if ( (Other == None) || Other.bStatic ) return; P = Pawn(Other); //the pawn we might have bumped into if ( P != None) //if we hit a pawn { if (P.Health >1) //as long as pawns health is more than 1 { P.Health --; // eat brains! mmmmm } } } defaultproperties { defaultMesh=SkeletalMesh'CH_IronGuard_Male.Mesh.SK_CH_IronGuard_MaleA' defaultAnimTree=AnimTree'CH_AnimHuman_Tree.AT_CH_Human' defaultAnimSet(0)=AnimSet'CH_AnimHuman.Anims.K_AnimHuman_BaseMale' defaultPhysicsAsset=PhysicsAsset'CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_Physics' Begin Object Name=WPawnSkeletalMeshComponent AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_Human' End Object RagdollLifespan=180.0 ControllerClass=class'TestZombieBot' }
Code:
class TestZombieBot extends GameAIController; var Pawn thePlayer; //variable to hold the target pawn simulated event PostBeginPlay() { super.PostBeginPlay(); } event SeePlayer(Pawn SeenPlayer) //bot sees player { if (thePlayer ==none) //if we didnt already see a player { thePlayer = SeenPlayer; //make the pawn the target GoToState('Follow'); // trigger the movement code } } state Follow { Begin: if (thePlayer != None) // If we seen a player { MoveTo(thePlayer.Location); // Move directly to the players location GoToState('Looking'); //when we get there } } state Looking { Begin: if (thePlayer != None) // If we seen a player { MoveTo(thePlayer.Location); // Move directly to the players location GoToState('Follow'); // when we get there } } defaultproperties { }
http://forums.epicgames.com/showthread.php?t=801590
http://forums.epicgames.com/showthread.php?t=799268
http://forums.epicgames.com/showthread.php?t=798718
September Update:
Code:
class TestZombiePawn extends UTPawn Placeable; var Pawn P; // variable to hold the pawn we bump into var() int DamageAmount; //how much brain to munch simulated function PostBeginPlay() { super.PostBeginPlay(); //wake the physics up SetPhysics(PHYS_Falling); } //over-ride epics silly character stuff simulated function SetCharacterClassFromInfo(class<UTFamilyInfo> Info) { Return; } simulated event Bump( Actor Other, PrimitiveComponent OtherComp, Vector HitNormal ) { `Log("Bump"); Super.Bump( Other, OtherComp, HitNormal ); if ( (Other == None) || Other.bStatic ) return; P = Pawn(Other); //the pawn we might have bumped into if ( P != None) //if we hit a pawn { if (TestZombiePawn(Other) != None) //we hit another zombie { Return; //dont do owt } else { //use a timer so it just takes health once each encounter //theres other better ways of doing this probably SetTimer(0.1, false, 'EatSlow'); } } } simulated function EatSlow() { P.Health -= DamageAmount; // eat brains! mmmmm if (P.Health <= 0)//if the pawn has no health { P.Destroy(); //kill it } } defaultproperties { Begin Object Name=WPawnSkeletalMeshComponent AnimTreeTemplate=AnimTree'CH_AnimHuman_Tree.AT_CH_Human' SkeletalMesh=SkeletalMesh'CH_IronGuard_Male.Mesh.SK_CH_IronGuard_MaleA' AnimSets(0)=AnimSet'CH_AnimHuman.Anims.K_AnimHuman_BaseMale' PhysicsAsset=PhysicsAsset'CH_AnimCorrupt.Mesh.SK_CH_Corrupt_Male_Physics' End Object RagdollLifespan=180.0 //how long the dead body will hang around for AirSpeed=200 GroundSpeed=200 ControllerClass=class'TestZombieBot' bDontPossess=false DamageAmount=10 }

Comment