playMaker

Author Topic: [solved]Ennemy AI detect player  (Read 3568 times)

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
[solved]Ennemy AI detect player
« on: October 17, 2013, 06:00:03 PM »
Hi,
I am setting up an enemy AI, nothing too fancy for now, I am using unity pathfinding.
When the player trigger the enemy's collider it fires a linecast(the custom action jean wrote) between the player and the enemy and check if there is an obstacle.

The thing is when my Enemy is moving he won't perform the line cast check, since he is already busy moving.
Is there a way to shoot the linecast while performing SetDestination as a Gameobject ? or should another gameobject parented to the Enemy be responsible for this. I would rater not.....
Also what is the difference between the linecast action and nav mesh raycast ? is it similar ?
Thank you
-Yaniv
« Last Edit: October 19, 2013, 05:31:41 PM by Yanifska »
Visit my portfolio: http://www.yanivcahoua.com/

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Ennemy AI detect player
« Reply #1 on: October 18, 2013, 11:02:27 AM »
I think you just need to add another FSM or put the collision area check into the each state the enemy is using.

You want to segregate primary functions, like movement and 'brain' type of stuff so that you can trigger those sorts of things from a higher level.

This is a particularly good article on the topic:
http://web.media.mit.edu/~jorkin/gdc2006_orkin_jeff_fear.pdf

It explains a little better how to separating those systems and having the brain and motor in a feedback loop can result in unique behaviors if you take the time to define conditions.

Here is another useful link, but may not be directly applicable to your problem, just good information:
http://red3d.com/cwr/steer/
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: Ennemy AI detect player
« Reply #2 on: October 18, 2013, 11:13:29 AM »
So I had to make another fsm on the same object. I have one fsm that is checking if the player is in sight and that sends  events the other fsm that is in charge of moving and updating the Enemy status.
Visit my portfolio: http://www.yanivcahoua.com/

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: Ennemy AI detect player
« Reply #3 on: October 19, 2013, 06:22:29 AM »
@Lane, I missed your post somehow, very inspiring articles thanks.
Visit my portfolio: http://www.yanivcahoua.com/