playMaker

Author Topic: Puppet2D Flip Action  (Read 211 times)

Thore

  • Playmaker Newbie
  • *
  • Posts: 47
    • View Profile
Puppet2D Flip Action
« on: April 11, 2017, 07:26:33 AM »
If you are using Puppet2D, you probably want to flip the character to move in the opposite direction. This tiny action will help you do that.

How to Use Custom Actions
  • Have a folder for custom actions, e.g. Assets/Playmaker/Actions Custom. You can then later copy that folder for use in another project.
  • Create the file manually, or use Playmaker's Custom Action Wizard (under Playmaker > Tools)
  • The file's name must be identical to the name given as public class ("Puppet2DFlip"). Any such name can only exist once in the project, but you can change it as long as you keep it consistent.

Puppet2DFlip.cs

Code: [Select]
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

namespace HutongGames.PlayMaker.Actions
{

[ActionCategory(ActionCategory.Animation)]
[Tooltip("Flip character using the Puppet2D Flip variable")]
public class Puppet2DFlip : FsmStateAction
{
Puppet2D_GlobalControl script;
public FsmGameObject globalCTRL;
public FsmBool flip;

public override void OnEnter()
{
script = globalCTRL.Value.GetComponent<Puppet2D_GlobalControl>();
script.flip = flip.Value;
Finish();
}
}

}
« Last Edit: April 11, 2017, 07:29:21 AM by Thore »