Been working on a hide-and-seek game (just flavor, not technical context), player gameObjects will run several FSMs to deal with input/movement, collision and word interaction, etc.
I currently have a player controller script scraping inputs from InControl, storing them locally, then throwing them to a FSM by assigning values to local FSM variables. This setup works well on my player gameObject as long as it has only one FSM. Where I'm having trouble is in referencing a specific FSM (to which I can throw my InControl values).
I'm a total hack in C#, not much of a coder... maybe that's why I couldn't get this to work for me:
https://hutonggames.fogbugz.com/default.asp?W329 or this to work either:
https://matthewwaring.wordpress.com/2014/01/14/using-playmaker-with-code-quick-introduction/Script here (note: yes, I'm scraping everything from InControl, sending everything to a single FSM):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using InControl; // needed for InControl
public class seeker_controller_script : MonoBehaviour
{
// allows this script to interact with FSM attached to gameobject
public PlayMakerFSM theFsm;
//public static PlayMakerFSM FindFsmOnGameObject(GameObject go, string controller_input_FSM);
// declare variables to store input from controller
float leftStickX = 0f;
float leftStickY = 0f;
bool leftStickButton = false;
float rightStickX = 0f;
float rightStickY = 0f;
bool rightStickButton = false;
bool leftTrigger = false;
bool leftBumper = false;
bool rightTrigger = false;
bool rightBumper = false;
bool buttonO = false;
bool buttonA = false;
bool buttonU = false;
bool buttonY = false;
bool dPadLeft = false;
bool dPadRight = false;
bool dPadUp = false;
bool dPadDown = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
// device input setup
var seekerPlayerDevice = InputManager.Devices[0];
// assign input from controller to local variables
leftStickX = seekerPlayerDevice.LeftStickX;
leftStickY = seekerPlayerDevice.LeftStickY;
leftStickButton = seekerPlayerDevice.LeftStickButton;
rightStickX = seekerPlayerDevice.RightStickX;
rightStickY = seekerPlayerDevice.RightStickY;
rightStickButton = seekerPlayerDevice.RightStickButton;
leftTrigger = seekerPlayerDevice.LeftTrigger;
leftBumper = seekerPlayerDevice.LeftBumper;
rightTrigger = seekerPlayerDevice.RightTrigger;
rightBumper = seekerPlayerDevice.RightBumper;
buttonO = seekerPlayerDevice.Action1;
buttonU = seekerPlayerDevice.Action2;
buttonY = seekerPlayerDevice.Action3;
buttonA = seekerPlayerDevice.Action4;
dPadLeft = seekerPlayerDevice.DPadLeft;
dPadRight = seekerPlayerDevice.DPadRight;
dPadUp = seekerPlayerDevice.DPadUp;
dPadDown = seekerPlayerDevice.DPadDown;
// assign locally stored input from controller to PlayMaker FSM variables - must also create these in FSM!!
theFsm.FsmVariables.GetFsmFloat("moveX").Value = leftStickX;
theFsm.FsmVariables.GetFsmFloat("moveZ").Value = leftStickY; // note: leftStickY controls moveZ!!
theFsm.FsmVariables.GetFsmBool("leftStickButton").Value = leftStickButton;
theFsm.FsmVariables.GetFsmFloat("rightStickX").Value = rightStickX;
theFsm.FsmVariables.GetFsmFloat("rightStickY").Value = rightStickY;
theFsm.FsmVariables.GetFsmBool("rightStickButton").Value = rightStickButton;
theFsm.FsmVariables.GetFsmBool("leftTrigger").Value = leftTrigger;
theFsm.FsmVariables.GetFsmBool("leftBumper").Value = leftBumper;
theFsm.FsmVariables.GetFsmBool("rightTrigger").Value = rightTrigger;
theFsm.FsmVariables.GetFsmBool("rightBumper").Value = rightBumper;
theFsm.FsmVariables.GetFsmBool("buttonO").Value = buttonO;
theFsm.FsmVariables.GetFsmBool("buttonU").Value = buttonU;
theFsm.FsmVariables.GetFsmBool("buttonY").Value = buttonY;
theFsm.FsmVariables.GetFsmBool("buttonA").Value = buttonA;
theFsm.FsmVariables.GetFsmBool("dPadLeft").Value = dPadLeft;
theFsm.FsmVariables.GetFsmBool("dPadRight").Value = dPadRight;
theFsm.FsmVariables.GetFsmBool("dPadUp").Value = dPadUp;
theFsm.FsmVariables.GetFsmBool("dPadDown").Value = dPadDown;
}
}
Any insight would be helpful! Thank you.