Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Vallar on March 11, 2013, 06:06:01 AM

Title: Creating AI with Patrol[Solved]
Post by: Vallar on March 11, 2013, 06:06:01 AM
Hello,

So I hit a snag again, unfortunately!

I have a mob that I am creating that needs to patrol a specific area and when the player would come to a certain distance from this mob the mob would play the alert animation and then when the player comes closer, would taunt the player.
Finally, when the player comes close enough, he would attack the player.

Here is my setup.

1- The patrol system:
I created an empty game object called "Waypoint Manager" and created 6 boxes (with deleted collisions and meshes) and added a FSM that randomly picks one of the boxes and plays the "walk" animation on the mob and sends it to that direction. The FSM is attached to the Waypoint Manager

So far that system works perfectly fine.

2- The state system:
I created an FSM on the mob itself and have a state with the "Get Distance" action which measures the distance every frame between the mob and the player. Float compare was used then to compare the distance and then flow through 1 of the three states (alert, taunt and attack).
In each of the states, I have the "Stop Animation" action that stops the animation from playing. However, I would like the mob to stop the movement however (as it still moves). I can't find a "Stop Action" or "Over rule Action" in the list of actions that I can make it stop the actions in "Waypoint Manager" from playing until the distance of the player is far more than what is required for the different states (alert = 11.2; taunt = 6; attack = 4.2).

Is there a way to do this?

Thank you very much in advance.

EDIT: Thank you everyone you have solved it all :D
Title: Re: Creating AI with Patrol
Post by: greg on March 11, 2013, 07:40:34 AM
I'd have a string switch, and only do waypoint wandering if the string = "wandering".. and have the state manager change the string according to the state.
Title: Re: Creating AI with Patrol
Post by: Vallar on March 11, 2013, 12:55:40 PM
That does sound like a good work around.  I will give it a try, thank you very much!
Title: Re: Creating AI with Patrol
Post by: Lane on March 11, 2013, 01:08:20 PM
You can use Get FSM State to check if the targeted fsm it's in a state named "whatever" or a string variable.

Used it yesterday, i think that was the name of the action. It works great.

edit: spelling errors from phone
Title: Re: Creating AI with Patrol
Post by: Sobek on March 12, 2013, 11:01:38 AM
Here is a link to some Playmaker AI tutorials that might can help you:

Title: Re: Creating AI with Patrol
Post by: Vallar on March 12, 2013, 11:18:17 AM
Hello,

Thank you very much all of you. I am trying everyone of your suggestion to see which is the best that suits my setup.

Thank you very much.