playMaker

Author Topic: Aircraft/Flight AI and pathfinding  (Read 23244 times)

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Aircraft/Flight AI and pathfinding
« Reply #15 on: December 22, 2013, 08:50:48 AM »
Thanks, I'll put something together in a couple of days

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: Aircraft/Flight AI and pathfinding
« Reply #16 on: January 10, 2014, 12:48:42 PM »
Same here.  I did watch your demo a bit, at one point the AI decided a perfect circle was the way to go and it kept that up.

I'd like to see either what you did via screen shots of your FSMs or something like that.  I've been playing with UnitySteer and Rain, but similar headaches as everyone else has had.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Aircraft/Flight AI and pathfinding
« Reply #17 on: January 10, 2014, 02:39:33 PM »
Take a look at this and let me know if it works. This is the AI, ship and basic chase combat ai.

http://dl.dropboxusercontent.com/u/38606641/Brevis/AI/AI-Test.unitypackage

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Aircraft/Flight AI and pathfinding
« Reply #18 on: January 10, 2014, 02:45:23 PM »
Bah, I forgot to include a couple of custom actions.

Here's a package with the custom actions. You may aleady have these in your project so I'd recommend importing both of these into a new project to avoid errors in the console about duplicates.

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: Aircraft/Flight AI and pathfinding
« Reply #19 on: January 10, 2014, 04:24:18 PM »
Looks like it's missing some components -

Dude\EnemyLauncher - what goes in the Create Object?
Dude\MotorAim - FSM - what Action is in Check path below Raycast?
Dude\Raycaster Prefab - FSM - what Action is in Raycaster below Set Vector3 XYZ?

Also MonoBehavior above Combat FSM on Dude is missing.
« Last Edit: January 10, 2014, 04:27:34 PM by Redhawk »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Aircraft/Flight AI and pathfinding
« Reply #20 on: January 10, 2014, 05:36:33 PM »
Quote
Dude\EnemyLauncher - what goes in the Create Object?

Its a Missile, you can delete the EnemyLauncher item since I switched it to use the railgun and the error should go away.

Quote
Dude\MotorAim - FSM - what Action is in Check path below Raycast?

Check Path is experimental and on hold so it's skipping through it. The missing action is Raycast 2.

Quote
Dude\Raycaster Prefab - FSM - what Action is in Raycaster below Set Vector3 XYZ?

The missing action is Raycast 2.

Quote
Also MonoBehavior above Combat FSM on Dude is missing.

ArrayMaker Proxy, I'm not using it yet so you can freely delete it.


Thanks for clearly specifying the issues. I think all you need is Raycast 2 (it was in the action folder instead of the Custom Action folder so I missed it)

« Last Edit: January 10, 2014, 05:39:38 PM by Lane »

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: Aircraft/Flight AI and pathfinding
« Reply #21 on: January 10, 2014, 05:44:05 PM »
On MotorAim - Once I put Raycast 2 in - should it be Hit Event = NoClearPath, No Hit Event = Finished?

Also - EnemyRail FSM - Looks like the last action is unable to find it's target.
EnemyRail : FSM : zzZzZzzzz.... : SubtractFsmFloat : Could not find FSM: Health
« Last Edit: January 10, 2014, 05:57:03 PM by Redhawk »

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: Aircraft/Flight AI and pathfinding
« Reply #22 on: January 10, 2014, 06:45:13 PM »
I think that you have a very solid AI.  Seriously.  I'm going to play around with this, but I like how it flows.

Only thing I would add is an additional FSM that checks to see if there is no Agent Anchor, then drop one at the point that the Dude ship is at.  I dropped your Health FSM (I saved it as a template) on the Enemy_forTheAi and once the ship destroys this enemy, then it keeps going back trying to shoot nothing (i.e. it stored the last position, where the enemy died) and keeps going for that.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Aircraft/Flight AI and pathfinding
« Reply #23 on: January 11, 2014, 08:28:10 AM »
Thanks, I'm glad to get some fresh eyes on it. :)

The warning was from the target the rail hit not having a health fsm. Looks like you added one.

The ai will loop around and shoot nothing because its firing is based on the angle to target, we'll have to leave the combat state and go back to wandering if we want to stop firing. That hadn't been put in yet i just got started on combat.

If you make some progress post it up, I'm interested in new ideas and improvements. There is still a lot to be done yet :)

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: Aircraft/Flight AI and pathfinding
« Reply #24 on: January 11, 2014, 10:00:20 AM »
Yes, being able to return to Wander would be good.  I was playing around with that but haven't gotten it to work yet.

I changed the MotorBrain a bit, but still not working the way I expected:
- New Vector3 to store BattleTarget Position
- Removed setting parent of AgentAnchor to BattleTarget (AgentAnchor stays it's own parent)
- In Set To Chase Mode = Set AgentAnchor position to BattleTargetVector3
- In Chase Mode
   = Set AgentAnchor based on whatever updated position BattleTarget is in
   = Game Object is Null - battleTarget = Is Null - StopChasing
   = StopChasing should probably go to Set To Wander Mode

Issues - Something in your FSMs keeps resetting the AgentAnchor to 0,0,0 but I can't figure out what.  Once I figure that out I can test to see if the above works.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Aircraft/Flight AI and pathfinding
« Reply #25 on: January 11, 2014, 11:24:54 AM »
So, what are you using to get the battle target vector? If you're just setting it to the position of the BattleTarget object, then you might as well just parent it and save a process.

The Anchor being moved to the Battle Target might end up being a clunky method, the behavior of the agent is vastly changed when you adjust the minimum distance to the Anchor during combat and I'm thinking of ways to avoid doing that or using an array system to gather nearby obstacles to weigh in a safe direction vector and also weigh that against a projected path of the Battle Target.. So theres some advanced things that need to happen in the brain, I think, to make the system more stable than it is now.

The idea is to let Brain just collect data and decide what 'state' the entity should be in - ie Wander, Combat, Flee, Follow, etc... Then in those states its sending downstream events to the other FSM's to activate certain paths of actions to keep it all modular. That'll allow us to build everything separate, define conditions in the brain, then send messages to the other FSM's about doing specific things. I think ideally the Brain would just be collecting data, deciding what state to be in or deciding what things need to be done and just telling the other FSM's to do it and they'll have all of the dirty vectors and such down in those FSM's.

Here's a good theory reference for the weight ideas and array. I think without adding some context for the brain to consider then the AI is always going to be a little dumb and non-persistent in the big picture.

http://arges-systems.com/blog/2012/07/03/unitysteer-updates-tospherical-obstacle-avoidance/
« Last Edit: January 11, 2014, 11:29:18 AM by Lane »

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: Aircraft/Flight AI and pathfinding
« Reply #26 on: January 11, 2014, 11:39:10 AM »
I'm still playing around with it.  I'm thinking about adding an AgentAnchor to each Enemy and leaving the default one at origin then just switching.

I really don't think that you need to make this AI more complicated.  The movement is good.  The flow is good.  It just needs some tweaks.  For instance, it needs to target a little better and shoot more often once it's in range (it takes a long time to kill an object).  Also it might need a runaway state.  I'm actually fairly close to some basic changes without really changing all your stuff because you have done an excellent job setting this up (much better than I could have done).


Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: Aircraft/Flight AI and pathfinding
« Reply #27 on: January 11, 2014, 02:13:09 PM »
Here's the package containing ONLY the Prefab Dude & Enemy updated with some changes. 
Issues - The Ai runs into asteroids and gets stuck pushing them.  Where should he wander once the Enemy is finally destroyed.

Changes - Some changes to MotorBrain, Health
Health = When he dies, tell Dude MotorBrain that he's dead
MotorBrain - see comments

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: Aircraft/Flight AI and pathfinding
« Reply #28 on: January 11, 2014, 09:40:09 PM »
FYI - I finally got some flying AI to work using Rain Indie.  I might post something up on their forum in the next day or so.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: Aircraft/Flight AI and pathfinding
« Reply #29 on: January 12, 2014, 09:04:55 AM »
Really? Thats great! It's flight AI using all 3 directions?