Darkhitori

vThirdPersonMotor/GroundAngleFromDirection

Jan 13th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. //Darkhitori v1.0
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Invector.CharacterController;
  6.  
  7. namespace HutongGames.PlayMaker.Actions
  8. {
  9.     [ActionCategory("Invector/vThirdPersonMotor")]
  10.     [Tooltip("Return the angle of ground based on movement direction ")]
  11.     public class vTPM_GroundAngleFromDirection : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vThirdPersonMotor))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         [ActionSection("Return")]
  18.         [UIHint(UIHint.FsmFloat)]
  19.         public FsmFloat movementAngle;
  20.        
  21.         public FsmBool everyFrame;
  22.  
  23.         vThirdPersonMotor theScript;
  24.  
  25.  
  26.         public override void Reset()
  27.         {
  28.             gameObject = null;
  29.             movementAngle = null;
  30.             everyFrame = true;
  31.         }
  32.        
  33.         public override void OnEnter()
  34.         {
  35.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  36.  
  37.             theScript = go.GetComponent<vThirdPersonMotor>();
  38.  
  39.  
  40.             if (!everyFrame.Value)
  41.             {
  42.                 DoTheMagic();
  43.                 Finish();
  44.             }
  45.  
  46.         }
  47.  
  48.         public override void OnUpdate()
  49.         {
  50.             if (everyFrame.Value)
  51.             {
  52.                 DoTheMagic();
  53.             }
  54.         }
  55.  
  56.         void DoTheMagic()
  57.         {
  58.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  59.             if (go == null)
  60.             {
  61.                 return;
  62.             }
  63.            
  64.             movementAngle.Value = theScript.GroundAngleFromDirection();            
  65.         }
  66.  
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment