Advertisement
Darkhitori

CF_closestPointOnTransformWidthLine

Jan 20th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 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/Ledge2LedgeTrigger")]
  10.     [Tooltip("Get closest point from point to transforms width line. ")]
  11.     public class CF_closestPointOnTransformWidthLine : FsmStateAction
  12.     {
  13.         [RequiredField]
  14.         [CheckForComponent(typeof(Ledge2LedgeTrigger))]
  15.         public FsmOwnerDefault gameObject;
  16.        
  17.         public FsmGameObject t;
  18.         public FsmVector3 toPoint;
  19.         [ActionSection("Return")]
  20.         [UIHint(UIHint.FsmVector3)]
  21.         public FsmVector3 closest;
  22.  
  23.         public FsmBool everyFrame;
  24.  
  25.         Ledge2LedgeTrigger theScript;
  26.  
  27.  
  28.         public override void Reset()
  29.         {
  30.             gameObject = null;
  31.             t = null;
  32.             toPoint = null;
  33.             closest = new Vector3(0,0,0);
  34.             everyFrame = true;
  35.         }
  36.        
  37.         public override void OnEnter()
  38.         {
  39.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  40.  
  41.             theScript = go.GetComponent<Ledge2LedgeTrigger >();
  42.  
  43.  
  44.             if (!everyFrame.Value)
  45.             {
  46.                 DoTheMethod();
  47.                 Finish();
  48.             }
  49.  
  50.         }
  51.  
  52.         public override void OnUpdate()
  53.         {
  54.             if (everyFrame.Value)
  55.             {
  56.                 DoTheMethod();
  57.             }
  58.         }
  59.  
  60.         void DoTheMethod()
  61.         {
  62.             var go = Fsm.GetOwnerDefaultTarget(gameObject);
  63.             if (go == null)
  64.             {
  65.                 return;
  66.             }
  67.  
  68.             closest.Value = theScript.closestPointOnTransformWidthLine(t.Value.transform, toPoint.Value);            
  69.         }
  70.  
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement