playMaker

Author Topic: Very basic AI trouble  (Read 2095 times)

fffgpp

  • Playmaker Newbie
  • *
  • Posts: 1
Very basic AI trouble
« on: March 23, 2014, 08:04:18 PM »
note: the images in this post are larger than they appear, click for full-size.

I'm following the ( unofficial ) AI tutorial that is linked on the playmaker youtube account and I'm running into some issues..

Here's what my setup looks like:



When the enemy spawns, it makes a raycast to look for the player and stores that info in a game object variable ( gameobject_hit ):



Then I compare gameobject_hit with my First Person Controller which has the "P L A Y E R" tag:



If it hits the player, it's supposed to do the following ( move and rotate towards the player ):



but when I run it, it ALWAYS goes straight to the "keep looking" state, even though my FINISHED goes back to square one. Being in the line of sight of the enemy doesn't make any difference. It will look at me (possibly because this action is in the "spawn" state) but it doesn't move.



Any help would be great. It's probably something simple I'm not understanding, but this is extremely frustrating..

Flying Robot

  • Sr. Member
  • ****
  • Posts: 293
  • Od ton yebo redro
    • Flying Robot Studios
Re: Very basic AI trouble
« Reply #1 on: March 24, 2014, 01:51:41 AM »
Hey, you really posted the same screen 4 times. Instead of that, if you posted what's happening inside the states that would help detecting the problem.

The setup is pretty basic. I think you should try to use the PlayMaker Debug tools to figure out what's happening.

1st Step : You need to debug the ray of the ray cast and see if it's working correctly.
2nd Step : You need to debug the name of the gameobject_hit

Can you do these steps and post back with screens from that? I think while doing these steps, you will figure out the error by yourself.


Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Very basic AI trouble
« Reply #2 on: March 24, 2014, 07:27:29 AM »
It's not a good loop, in either result from the compare it will return to doing the raycast on the next frame before it really has enough time to properly react to what its supposed to do in that state.

So its basically doing a raycast, then if it hits something it will store the object.
Then it will compare that to a player tag.
If true, it goes into a chase state with look at/move towards and on the next frame immediately leaves the state to recycle the loop.
If false, it just recycles the loop, just going in circles instead of doing something intuitive.

If you didn't have the next frame event actions in there then it would be throwing 1000+ loop errors regularly and thats the sure sign of a bad loop.

I would make an FSM that does nothing but raycast, then mirror that data over to the other FSM which reacts to that data. This way you have two simultaneous FSMs doing different things but in parallel. When you do this you'll quickly start to see the way the ai should be structured and how you need to segment it and why the above system isnt working.

This might be useful reference material. I made an update on my flight AI last night and explained a little bit about the segmentation.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D