-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFoxScript.cs
44 lines (41 loc) · 1015 Bytes
/
FoxScript.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
using UnityEngine;
public class FoxScript : MonoBehaviour
{
public float speed;
public Transform point1;
public Transform point2;
float value;
bool pointTo1;
bool pointTo2;
void Start()
{
transform.position = point2.position;
pointTo1 = true;
pointTo2 = false;
speed += Random.Range(-.25f, .25f);
}
private void Update()
{
transform.position = Vector3.Lerp(point2.position, point1.position, value);
if (pointTo1)
{
value += speed * Time.deltaTime;
transform.LookAt(point1.position);
}
if (value >= 1)
{
pointTo1 = false;
pointTo2 = true;
}
if (value <= 0)
{
pointTo2 = false;
pointTo1 = true;
}
if (pointTo2)
{
value -= speed * Time.deltaTime;
transform.LookAt(point2.position);
}
}
}