-
Notifications
You must be signed in to change notification settings - Fork 3
/
GetSphereColliderRadius.cs
58 lines (44 loc) · 1.37 KB
/
GetSphereColliderRadius.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
// License: Attribution 4.0 International (CC BY 4.0)
/*--- __ECO__ __PLAYMAKER__ __ACTION__ ---*/
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Physics)]
[Tooltip("Get the size of a Sphere Collider")]
[HelpUrl("")]
public class GetSphereColliderRadius : ComponentAction<Rigidbody>
{
[RequiredField]
[CheckForComponent(typeof(SphereCollider))]
[Tooltip("The GameObject to apply the size to.")]
public FsmOwnerDefault gameObject;
[Tooltip("Sphere radius")]
public FsmFloat radius;
[Tooltip("Repeat every frame while the state is active.")]
public FsmBool everyFrame;
public override void Reset()
{
gameObject = null;
radius = null;
everyFrame = false;
}
public override void OnEnter()
{
DoChange();
if (!everyFrame.Value)
{
Finish();
}
}
public override void OnFixedUpdate()
{
DoChange();
}
void DoChange()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
SphereCollider collider = go.GetComponent<SphereCollider>();
radius.Value = collider.radius;
}
}
}