playMaker

Author Topic: Special AI Behaviour  (Read 937 times)

MiyuHimano

  • Playmaker Newbie
  • *
  • Posts: 2
Special AI Behaviour
« on: January 05, 2019, 03:23:41 PM »
Hello Playmaker community :)

I'm still learning Playmaker and started to use it in my test game project.
I like the way how to use it, because it reminds me of writing code by myself, but this is another story ;)

I created an enemy with AI (based on Raycast) with conditions like distance, angle and visibility of the player, based on a tutorial from this website.

I created my own movement behaviour and it works like it should right now.
But now I'm thinking of optimizing the graph in Playmaker.

The attached screenshot is from inside the Movement FSM. I'll go throu the important parts to get you a better view.


"How long to chase?"
A bool test on a variable wich is set by an incomming projectile from the player.
If we hit the enemy while he's in idle mode,  he will be very angry on us :D
and he will chase the player for a longer time (distance). If he only see us in range, he will follow the player a much shorter distance (if we run away).
This is the piont where I use a Bool Test and check for true/false. In pendency of this result I set a float variable with the ChaseTime (higher number for true, lower(normal) for false).

Is there a one node solution for this or is it ok like it's done? It's not a big problem for me, because it's working, just want to learn a good pattern :)

>>in short:
Test a bool -> if true set float VAR to X / if false set float VAR to Y


"Set Start Position":
>> what does it do
I want the enemy go back to it's very first position from where he saw the player or where he was while the player hits him the first time, after the chase time is over.

>> how I did
I use a helper bool variable. If it's true(default), then I set it false and save the current position of the enemy and chase the player.
If I come to this node again (e.g. enemy attacked the player, player runs away, enemy chase player again), I go directly to "Chase Player". With all of this the enemy can remember he's very first position.
If he returned to his starting point, all variables will be reset.

>>in short
test bool -> if true, set location/ if false, don't save location

This is the way I would do this in C# and if I understood it correctly, that's how you build up your FSMs in Playmaker.
Like I said before, I just need some feedback of my FSM design to get the lightweight way in future.

Thanks in advance and have a nice weekend,

David

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Special AI Behaviour
« Reply #1 on: January 06, 2019, 09:59:41 AM »
Hi.
This looks fine.

A good thing also is that you document well, as many tend to skip that (like me when i started)

You can also change the color of your states, i use that to 'group' states
as well as color the transition, but that i don't use much myself :)