daily pastebin goal
76%
SHARE
TWEET

ThirdPersonCamera/SetMainTarget

Darkhitori Jan 12th, 2018 (edited) 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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/vThirdPersonCamera")]
  10.     [Tooltip("Set the target for the camera ")]
  11.     public class vTPC_SetMainTarget : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(vThirdPersonCamera))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public FsmGameObject newTarget;
  18.        
  19.         public FsmBool everyFrame;
  20.  
  21.         vThirdPersonCamera theScript;
  22.  
  23.  
  24.         public override void Reset()
  25.         {
  26.             gameObject = null;
  27.             newTarget = null;
  28.             everyFrame = true;
  29.         }
  30.        
  31.         public override void OnEnter()
  32.         {
  33.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  34.  
  35.             theScript = go.GetComponent<vThirdPersonCamera>();
  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.SetMainTarget(newTarget.Value.transform);            
  63.         }
  64.  
  65.     }
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top