Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * Adventure Creator
- * by Chris Burton, 2013-2015
- *
- * "ActionTemplate.cs"
- *
- * This is a blank action template.
- *
- */
- using UnityEngine;
- using System.Collections;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- namespace AC
- {
- //this allows AC the functionality to toggle "apply root motion" on the Animator of a NPC,
- //why? we need it on for anims where the guy walks around, but off when the guy follows a path
- [System.Serializable]
- public class RSL_AC_ActionToggleApplyRootMotion : Action
- {
- // Declare variables here
- public GameObject objectToAffect;
- public bool newRootMotionState;
- public RSL_AC_ActionToggleApplyRootMotion ()
- {
- this.isDisplayed = true;
- category = ActionCategory.Custom;
- title = "Character: Toggle Root Motion";
- description = "This is a blank Action template.";
- }
- override public float Run ()
- {
- /*
- * This function is called when the action is performed.
- *
- * The float to return is the time that the game
- * should wait before moving on to the next action.
- * Return 0f to make the action instantenous.
- *
- * For actions that take longer than one frame,
- * you can return "defaultPauseTime" to make the game
- * re-run this function a short time later. You can
- * use the isRunning boolean to check if the action is
- * being run for the first time, eg:
- */
- if (objectToAffect && objectToAffect.GetComponent<Animator>())
- {
- objectToAffect.GetComponent<Animator>().applyRootMotion = newRootMotionState;
- }
- return 0f;
- }
- #if UNITY_EDITOR
- override public void ShowGUI ()
- {
- // Action-specific Inspector GUI code here
- objectToAffect = (GameObject) EditorGUILayout.ObjectField ("GameObject to affect:", objectToAffect, typeof (GameObject), true);
- newRootMotionState = EditorGUILayout.Toggle ("New root motion state:", newRootMotionState);
- AfterRunningOption ();
- }
- public override string SetLabel ()
- {
- // Return a string used to describe the specific action's job.
- // Return a string used to describe the specific action's job.
- if (objectToAffect)
- {
- return (" (" + objectToAffect.name + " - " + newRootMotionState.ToString () + ")");
- }
- return "";
- }
- #endif
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement