-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleProgrammablePlayableTest.cs
More file actions
38 lines (38 loc) · 1.1 KB
/
SimpleProgrammablePlayableTest.cs
File metadata and controls
38 lines (38 loc) · 1.1 KB
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
using UnityEngine;
namespace Emptybraces.Timeline
{
public class SimpleProgrammablePlayableTest : MonoBehaviour, ISimpleProgrammablePlayableReceiver
{
[SerializeField] float _speed;
[SerializeField] float _power;
Rigidbody _rb;
Vector3 _p;
void Awake()
{
_rb = transform.GetComponentInChildren<Rigidbody>(true);
_rb.gameObject.SetActive(false);
_p = transform.position;
}
public void OnNotify(float value, bool isEnter, bool isExit)
{
if (!Application.isPlaying)
_rb = transform.GetComponentInChildren<Rigidbody>(true);
if (isEnter)
_rb.gameObject.SetActive(true);
else if (isExit)
{
// _rb.gameObject.SetActive(false);
return;
}
_rb.transform.localScale = Mathf.Lerp(0.1f, 2, value) * Vector3.one;
var pos = _p;
pos.x += (Mathf.PerlinNoise(Time.time * _speed, .1f + Time.time * _speed) - 0.5f) * _power;
pos.y += (Mathf.PerlinNoise(.2f + Time.time * _speed, .3f + Time.time * _speed) - 0.5f) * _power;
if (!Application.isPlaying)
_rb.transform.localPosition = pos;
else
_rb.MovePosition(pos);
cn.logBluef(value, isEnter, isExit);
}
}
}