-
Notifications
You must be signed in to change notification settings - Fork 3
/
GetYDistance.cs
64 lines (47 loc) · 1.54 KB
/
GetYDistance.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.GameObject)]
[Tooltip("Measures the Y Distance betweens 2 Game Objects and stores the result in a Float Variable.")]
public class GetYDistance : FsmStateAction
{
[RequiredField]
[Tooltip("Measure distance from this GameObject.")]
public FsmOwnerDefault gameObject;
[RequiredField]
[Tooltip("Target position.")]
public FsmVector3 target;
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("Store the distance in a float variable.")]
public FsmFloat distance;
[Tooltip("Repeat every frame.")]
public bool everyFrame;
public override void Reset()
{
gameObject = null;
target = null;
distance = null;
everyFrame = true;
}
public override void OnEnter()
{
DoGetYDistance();
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
DoGetYDistance();
}
void DoGetYDistance()
{
float firstYPos = gameObject.GameObject.Value.transform.position.y;
float secondYPos = target.Value.y;
distance.Value = firstYPos = secondYPos;
}
}
}