Advertisement
Darkhitori

CF_closestPoint

Jan 20th, 2018
109
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 MLSpace;
  6.  
  7. namespace HutongGames.PlayMaker.Actions
  8. {
  9.     [ActionCategory("CombatFramework/Trigger")]
  10.     [Tooltip("Get closest point to this trigger. Return null to disable. ")]
  11.     public class CF_closestPoint : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(Trigger))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public FsmVector3 toPoint;
  18.        
  19.         public FsmBool everyFrame;
  20.  
  21.         Trigger theScript;
  22.  
  23.  
  24.         public override void Reset()
  25.         {
  26.             gameObject = null;
  27.             toPoint = new Vector3(0,0,0);
  28.             everyFrame = true;
  29.         }
  30.        
  31.         public override void OnEnter()
  32.         {
  33.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  34.  
  35.             theScript = go.GetComponent<Trigger>();
  36.  
  37.  
  38.             if (!everyFrame.Value)
  39.             {
  40.                 DoTheMethod();
  41.                 Finish();
  42.             }
  43.  
  44.         }
  45.  
  46.         public override void OnUpdate()
  47.         {
  48.             if (everyFrame.Value)
  49.             {
  50.                 DoTheMethod();
  51.             }
  52.         }
  53.  
  54.         void DoTheMethod()
  55.         {
  56.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  57.             if (go == null)
  58.             {
  59.                 return;
  60.             }
  61.  
  62.             theScript.closestPoint(toPoint.Value);            
  63.         }
  64.  
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement