Advertisement

Combat Behaviour and movement

Started by August 04, 2006 03:54 AM
4 comments, last by GameDev.net 18 years, 3 months ago
Hello Once Again! I have to deliever a demo in the ed of august. Everithing is still in development, and the Ai in the very beggining to :P. In this Pre-pre-alpha demo we just have one type of agent, and only one enemy (the player). Because of the litle time, I'm going to put every behaviour in a FSM for now. Later I'll implement some kind of planning and more cognitive/non-deterministic algorithms :). My main problem rigth now is not how do I mount the FSM is more How should I mount the combat movement. The State machine is something like: Patrol, If see player attack and send message to closer friend. Now How should I do the attack? I pick an action randomly, like melee or fire. Melee it's easy, just go to the player and figth. The other attacks the agent should fire a gun (I have already some algorithm to fire and miss or fire to kill). But when Firing should they keep walking bakwardsl, straffing, and other movement, should they keep in the same place and shoot... Some ideas may help me a litle bit. Thanks :)
Simple:

void Unit::Update(){if (Target!=0 && DistanceTo(Target) < WeaponRange)  {    //Shoot  }  else  {  //Move to pursue or move to next path.  }}


This works for basic RTS gameplay, but for FPS games this is not quite enough thou...



EDIT:

Oh, I mis-read your post... sorry for that. :D

How your units should behave depends a lot on what kind of game, i.e FPS, RTS...
Simple AI can detect if a player is shooting at them, and if reloading - attempt to strafe/move away from the shot.

It's all in imagining what a real person would do! :)
"Game Maker For Life, probably never professional thou." =)
Advertisement
I'm talking about a FPS.
something that worked well for us in a past game was to decouple upper and lower body animations. The lower body is basically run by the locomotor, the upper body is basically run by the weapons system.

Movement commands are placed via the locomotor:
locomotor->moveto( position );

Firing is left up to the weapons system:
weaponSystem->startFiring();
weaponSystem->stopFiring();

So basically, the behaviors use the locomotor to move, and activate/deactivate the weapons system at appropriate times. A move to position then fire behavior wouldn't activate the weapon system until the move was done. A move while firing would actiavte the weapon system as soon as it started. The weapon system handles everything to do with: "do i have line of sight", "do i need to reload", etc.

You'll need some artful animation blending to make it look right. =)

-me
Quote: Original post by Palidine
something that worked well for us in a past game was to decouple upper and lower body animations. The lower body is basically run by the locomotor, the upper body is basically run by the weapons system.

Movement commands are placed via the locomotor:
locomotor->moveto( position );

Firing is left up to the weapons system:
weaponSystem->startFiring();
weaponSystem->stopFiring();

So basically, the behaviors use the locomotor to move, and activate/deactivate the weapons system at appropriate times. A move to position then fire behavior wouldn't activate the weapon system until the move was done. A move while firing would actiavte the weapon system as soon as it started. The weapon system handles everything to do with: "do i have line of sight", "do i need to reload", etc.

You'll need some artful animation blending to make it look right. =)

-me


The blendings and the animations are all set! It is done something like that.. The weapon system is decoupled from the body/movement system. My robot agent can fire at walking, just fire, just walk, etc...

My mains question is how to do the movement in combat behaviour with a FSM!
setup a switch with different cases, maybe have one for your lower bodya and one for your upper body/weapons.

---lowerBodySwitch---
case patrolling:
//patrolling function.

case attackingMelee:
//attacking melee range function.

case attackingRanged:
//attacking at range function.

case chasing:
//chasing function.

case lostTarget:
//player ran out of range function.

---upperBodySwitch---

case lowerAction==patrolling && target==null:
//normal patrolling animation, IE: slow walk, gun in holster, etc.

case lowerAction==patrolling && target=="player1"
//transistion from partolling action to attacking action, IE: stop, determine if player is melee or range.

case lowerAction==attackingMelee && targetDistance 3:
//pick either chase, or take out gun and shoot.

case lowerAction==attackingMelee && targetDistance > weaponRange:
//switch lowerAction to chasing, take out gun, put away sword, whatever.


anyway you just do a bunch of stuff like this.

This topic is closed to new replies.

Advertisement