playMaker

Author Topic: FSM to control mesh NPC  (Read 3216 times)

Alternicity

  • Playmaker Newbie
  • *
  • Posts: 19
FSM to control mesh NPC
« on: November 14, 2015, 08:29:16 PM »
After doing the Access Control Clicking and Quests tutorial on youtube I wanted to put a reward behind the doors, and decided on a small robot walking around. I made some scenery for him to walk to, and interact with, all of it in Blender etc.

I've created a navmesh, and am wondering if there is any advice or tutorial links on getting the robot to be able to decide where to walk next and then go there. I want him to have a little life of his own - a sequence of 'go there and do this' type instructions.

How best to do this with Playmaker? I started sketching out an FSM, but am not really sure how to proceed.

Thanks for reading.


Alternicity

  • Playmaker Newbie
  • *
  • Posts: 19
Re: FSM to control mesh NPC
« Reply #1 on: November 18, 2015, 07:33:40 PM »
I have made some empty game objects and placed them at the locations I want the robot to go, and added a Get Vector XYZ and a Controller Move it's Playmaker node called 'Recharge'.

I'm trying to get the Empty Game Objects XYZ with the Get Vector, but don't seem to be able to. Is this the right way to go about it?

Alternicity

  • Playmaker Newbie
  • *
  • Posts: 19
Re: FSM to control mesh NPC
« Reply #2 on: November 18, 2015, 11:51:23 PM »
If I run it with this set up, and manually drag down his energy level in the inspector, we're getting to the recharge state, and there's some encouraging green bits, but the character is not moving.

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: FSM to control mesh NPC
« Reply #3 on: November 19, 2015, 01:27:30 AM »
Hello- You'll want to add a navmesh agent to your robot- download and install the Playmaker "unity Navmesh" actions https://hutonggames.fogbugz.com/default.asp?W1174

Then you can use the "Set destination as game object" action to have him walk to your game object
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: FSM to control mesh NPC
« Reply #4 on: November 19, 2015, 01:29:45 AM »
Hi,
For the getting the Vector of an object you can use the action "Get Position"

The action "Controller Move" is to move to a direction at a certain speed, it is not to move to a position.
You can try the action "Move Toward"

If the position to go to will always be the same you can remove the empty gameObject and only use the move toward action.
And set the target position manually on that action.

Alternicity

  • Playmaker Newbie
  • *
  • Posts: 19
Re: FSM to control mesh NPC
« Reply #5 on: November 19, 2015, 03:22:51 PM »
Many thanks mdotstrange and djaydino.
 :)

Alternicity

  • Playmaker Newbie
  • *
  • Posts: 19
Re: FSM to control mesh NPC
« Reply #6 on: December 06, 2015, 02:41:31 PM »


I am trying to get the NPC to rotate to face a certain/various directions.

SetAgentAsDestination works great for actually moving the character to one (I use Empties), but turning on the spot doesn't seem to have a SetAgentRotate or similar, and Rotate isn't working. How do I rotate my character?

In trying to figure this out I thought I'd get the character's forward facing vector as well, but am stuck at that as well - if anyone has any ideas, that'd be useful. :)

Thanks for reading.


mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: FSM to control mesh NPC
« Reply #7 on: December 06, 2015, 06:45:40 PM »
You could store the agent's destination as a game object variable- and use a smooth look at action to always look at the target or game objects of your choice-

Or you could play an animation when they reach the destination that has them look around-

If you are planning on doing a lot of NPC stuff I'd recommend taking a look at the asset Behavior Designer- it uses behavior tree's which make this kind of work really fast and easy as they were designed to do AI stuff-https://www.assetstore.unity3d.com/en/#!/content/15277

Workflow is very similar to Pmaker and has Pmaker integration/actions-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Alternicity

  • Playmaker Newbie
  • *
  • Posts: 19
Re: FSM to control mesh NPC
« Reply #8 on: December 07, 2015, 11:03:07 AM »
Thanks mdotstrange Smooth look at did the trick.

I looked at Behaviour Designer ( as well as Rain, and ICE) and settled on Playmaker.

It seems to me as thought there is a significant overlap in their functionality - is it really beneficial to use both simultaneously? Is there an online list comparing features? Is it common for devs to use both?

I think that unless I come up against a really huge obstacle, I'll try to make the most out of PM before trying another asset (although that said, I've always like the *look* of BD+ICE)

Thanks again.

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: FSM to control mesh NPC
« Reply #9 on: December 07, 2015, 06:47:05 PM »
Glad it worked out :)

Behavior Designer uses a different mechanism than Playmaker- Playmaker uses FSM's and Behavior Designer uses Behavior Tree's- Behavior Tree's were designed to do Ai so they do it very well- FSM's can do AI as well- they are just not optimized to do so- so some tasks can get really complex-

Here's a good article on behavior tree's http://www.gamasutra.com/blogs/ChrisSimpson/20140717/221339/Behavior_trees_for_AI_How_they_work.php



Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!