Advertisement
Darkhitori

vThirdPersonInput/ChangeCameraState

Jan 12th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 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/vThirdPersonInput")]
  10.     [Tooltip(" ")]
  11.     public class vTPI_ChangeCameraState : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vThirdPersonInput))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public FsmString cameraState;
  18.        
  19.         public FsmBool everyFrame;
  20.  
  21.         vThirdPersonInput theScript;
  22.  
  23.  
  24.         public override void Reset()
  25.         {
  26.             gameObject = null;
  27.             cameraState = "";
  28.             everyFrame = true;
  29.         }
  30.        
  31.         public override void OnEnter()
  32.         {
  33.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  34.  
  35.             theScript = go.GetComponent<vThirdPersonInput>();
  36.  
  37.  
  38.             if (!everyFrame.Value)
  39.             {
  40.                 DoTheMagic();
  41.                 Finish();
  42.             }
  43.  
  44.         }
  45.  
  46.         public override void OnUpdate()
  47.         {
  48.             if (everyFrame.Value)
  49.             {
  50.                 DoTheMagic();
  51.             }
  52.         }
  53.  
  54.         void DoTheMagic()
  55.         {
  56.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  57.             if (go == null)
  58.             {
  59.                 return;
  60.             }
  61.            
  62.             theScript.ChangeCameraState(cameraState.Value);            
  63.         }
  64.  
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement