I am in over my head with the amount of information I've been absorbing lately, to such a point that I only discovered this forum, which I have been wishing for for months, today. Well! Time to share some actions!
Here is an action that exposes all the variables within the CharacterMotor script:
using UnityEngine;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
[ActionCategory(ActionCategory.Character)]
[Tooltip("Interface to CharacterMotor component")]
public class CharacterMotorAction : FsmStateAction {
[RequiredField]
[CheckForComponent(typeof(CharacterMotor))]
public FsmOwnerDefault owner;
CharacterMotor motor;
GameObject previousGameObject;
public FsmBool CanControl = true;
public FsmFloat ForwardSpeed = 10f;
public FsmFloat SidewaysSpeed = 10f;
public FsmFloat BackwardsSpeed = 10f;
public FsmFloat MaxGroundAcceleration = 30f;
public FsmFloat MaxAirAcceleration = 20f;
public FsmFloat Gravity = 10f;
public FsmFloat MaxFallSpeed = 20f;
public FsmBool JumpingEnabled = true;
public FsmFloat BaseHeight = 1f;
public FsmFloat ExtraHeight = 4.1f;
public override void Reset()
{
owner = null;
}
public override void OnEnter ()
{
GameObject gameObject = Fsm.GetOwnerDefaultTarget(owner);
if (gameObject == null)
return;
if (gameObject != previousGameObject) {
motor = gameObject.GetComponent<CharacterMotor>();
previousGameObject = gameObject;
}
if (motor == null)
return;
CharacterMotorMovement movement = motor.movement;
CharacterMotorJumping jumping = motor.jumping;
motor.canControl = CanControl.Value;
movement.maxForwardSpeed = ForwardSpeed.Value;
movement.maxSidewaysSpeed = SidewaysSpeed.Value;
movement.maxBackwardsSpeed = BackwardsSpeed.Value;
movement.maxGroundAcceleration = MaxGroundAcceleration.Value;
movement.maxAirAcceleration = MaxAirAcceleration.Value;
movement.gravity = Gravity.Value;
movement.maxFallSpeed = MaxFallSpeed.Value;
jumping.enabled = JumpingEnabled.Value;
jumping.baseHeight = BaseHeight.Value;
jumping.extraHeight = ExtraHeight.Value;
}
}
Just look at it. It's so beautiful.
Here is another action which exposes the variables within the Platform Input Controller:
using UnityEngine;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
[ActionCategory(ActionCategory.Character)]
[Tooltip("Interface to PlatformInputController component")]
public class PlatformInputControllerAction : FsmStateAction {
[RequiredField]
[CheckForComponent(typeof(PlatformInputController))]
public FsmOwnerDefault owner;
PlatformInputController controller;
GameObject previousGameObject;
public FsmBool AutoRotate = true;
public FsmFloat MaxRotationSpeed = 360f;
public override void Reset()
{
owner = null;
}
public override void OnEnter ()
{
GameObject gameObject = Fsm.GetOwnerDefaultTarget(owner);
if (gameObject == null)
return;
if (gameObject != previousGameObject) {
controller = gameObject.GetComponent<PlatformInputController>();
previousGameObject = gameObject;
}
if (controller == null)
return;
controller.autoRotate = AutoRotate.Value;
controller.maxRotationSpeed = MaxRotationSpeed.Value;
}
}
They're like a cute couple, aren't they? They go well together, which is why I had my swell friend Martijn Zandvliet write them up for me. (I'm a pathetic scripter, but I blame PlayMaker for it).
I hope these are as useful for you all as they have been for me. Cheers!