This action gives you a jet pack boost effect you can turn on and off- I used the code from this tutorial to make the action
https://www.youtube.com/watch?v=OIPpU7_RNVMHere's the code- its also attached
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Character)]
[Tooltip("Boosts an object up for a jet pack like effect. Requires a character controller and a C# CharacterMotor script. ")]
public class JetPack : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(CharacterMotor))]
[CheckForComponent(typeof(CharacterController))]
[Tooltip("The game object to boost")]
public FsmOwnerDefault gameObject;
[Tooltip("Amount of jetpack boost")]
public FsmFloat fuel;
public FsmBool everyFrame;
CharacterMotor cm;
CharacterController cc;
public override void Reset()
{
gameObject = null;
fuel = null;
everyFrame = true;
}
public override void OnEnter()
{
if (!everyFrame.Value)
{
Finish();
}
}
public override void OnUpdate()
{
if (everyFrame.Value)
{
DoJetPack();
}
}
void DoJetPack()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go == null)
{
return;
}
// Do jet pack boost. Boost amount is controlled by fuel
cm = go.GetComponent<CharacterMotor>();
cc = go.GetComponent<CharacterController>();
Vector3 velocity = new Vector3(cc.velocity.x, fuel.Value, cc.velocity.z);
cm.SetVelocity(velocity);
}
}
}
The action requires a CharacterController and a CharacterMotor C# script on the object for it to work. I attached a version of the CharacterMotor C# script as well in case you need one.