playMaker

Author Topic: Running an FSM for a car driver  (Read 2049 times)

thierry_st_malo

  • Junior Playmaker
  • **
  • Posts: 58
Running an FSM for a car driver
« on: January 15, 2018, 08:57:51 AM »
Hi,

I am working on a car-based game with Playmaker. In the car's FSM I want to use the Run FSM action, calling four times the same FSM template, once for each wheel collider. Basically the Run FSM works very well ; the template is called four times, executes and returns properly in sequence.

But at this point I am lost. I think that in the template I should define the wheel collider and the Game Object that owns it as inputs. So far, so good. But:
1 - I don't want these inputs to be hard-coded, my intention being to re-se the whole system in other cars as a prefab.
2 - How do I define and access the template's inputs in the car's basic FSM, where the wheel colliders are defined?

You will find attached a basic version of the template.
Thanks in advance.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Running an FSM for a car driver
« Reply #1 on: January 17, 2018, 01:57:00 AM »
Hi,

 There are several ways but I am going to mention one that I use very often and works well:

 For each of your cars, you will adopt a set of convention:
at the top most Object, you will have an Fsm called "Meta Data", this FSM wil do nothing but host some variables ( your wheels objects or colliders, some properties like maximum speed, etc etc)

Then inside the car, all the Fsm dealing with specifics will ALWAYS refer to this Meta Data to access these properties.

This way, anywhere you are an don any of your future car prefabs, your logic WILL rely on the fact that they expect a "Meta Data" Fsm at the root of their instance and that it will have the variables it expects.

To access metaData, you'll use the actions GetFsmXXX and alwasy store the metadata value into a local variable for your Fsm, For clarity you could adopt a convention, so all local variable that have a value that is coming from the MetaData could start with # so MetaData:FsmVariable "Front Right Wheel Collider" will be called in any other fsm that needs to get this value "#Front Right Wheel Collider", then in the long run, you know where you are when you look at logics at a glance.

Does that make sense?

Bye,

 Jean

thierry_st_malo

  • Junior Playmaker
  • **
  • Posts: 58
Re: Running an FSM for a car driver
« Reply #2 on: January 17, 2018, 06:21:29 AM »
It DOES make sense.
Many thanks, Jean.

thierry_st_malo

  • Junior Playmaker
  • **
  • Posts: 58
Re: Running an FSM for a car driver
« Reply #3 on: January 17, 2018, 11:27:32 AM »
Hi again, Jean !
Sorry but nothing's obvious.
I use the action "Get Wheel Collider Ground Hit Properties" that comes from the Ecosystem.
For the Game Object, I use a wheel that has a Wheelcollider component. So far, so good.
For the "collider" parm, what should I use ? I had assumed it would be the terrain, but I can't drag it into the action's input box. In the action's .cs source code, this parm is described as an FsmGameObject.
I'm asking because I believe that you are this action's creator.

Thanks in advance.
« Last Edit: January 18, 2018, 03:23:12 AM by thierry_st_malo »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Running an FSM for a car driver
« Reply #4 on: January 19, 2018, 01:33:25 AM »
Hi,

 I am not sure I follow,

 this action doesn't need you to define the terrain, it will give you the properties of the last ground contact. the ground is not part of your prefab rig, it's part of the scenery right?

 Bye,

 Jean