Darkhitori

vHeadTrack/SetLookAtPosition

Jan 13th, 2018
134
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/vHeadTrack")]
  10.     [Tooltip(" ")]
  11.     public class vHT_SetLookAtPosition : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vHeadTrack))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public FsmVector3 point;
  18.        
  19.         public FsmFloat strafeHeadWeight;
  20.        
  21.         public FsmFloat spineWeight;
  22.        
  23.         public FsmBool everyFrame;
  24.  
  25.         vHeadTrack theScript;
  26.  
  27.         public override void Reset()
  28.         {
  29.             gameObject = null;
  30.             point = new Vector3(0,0,0);
  31.             strafeHeadWeight = null;
  32.             spineWeight = null;
  33.             everyFrame = true;
  34.         }
  35.        
  36.         public override void OnEnter()
  37.         {
  38.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  39.  
  40.             theScript = go.GetComponent<vHeadTrack>();
  41.  
  42.  
  43.             if (!everyFrame.Value)
  44.             {
  45.                 DoTheMagic();
  46.                 Finish();
  47.             }
  48.  
  49.         }
  50.  
  51.         public override void OnUpdate()
  52.         {
  53.             if (everyFrame.Value)
  54.             {
  55.                 DoTheMagic();
  56.             }
  57.         }
  58.  
  59.         void DoTheMagic()
  60.         {
  61.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  62.             if (go == null)
  63.             {
  64.                 return;
  65.             }
  66.             theScript.SetLookAtPosition(point.Value, strafeHeadWeight.Value, spineWeight.Value);
  67.                
  68.            
  69.         }
  70.  
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment