-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoveObjectByPoint.cs
More file actions
58 lines (55 loc) · 1.67 KB
/
MoveObjectByPoint.cs
File metadata and controls
58 lines (55 loc) · 1.67 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//Ака 47 епта
using UnityEngine;
public class MoveObjectByPoint : MonoBehaviour {
[SerializeField] protected int PointGood = 0;
[SerializeField] protected Transform[] Point = null;
[SerializeField] protected float smooth = 2f;
[SerializeField] protected bool ToMove = true;
[SerializeField] protected bool Restart = true;
[SerializeField] protected int Freeze = 500;
[SerializeField] [HideInInspector] protected float FreezeBegin;
void Start(){
FreezeBegin = Freeze;
}
// Update is called once per frame
void Update () {
if (Freeze == FreezeBegin) {
if (ToMove == true) {
if (Restart == false) {
if (Point.Length != PointGood) {
if (transform.localPosition == Point [PointGood].transform.localPosition) {
PointGood++;
Freeze = 0;
}
if(Freeze == FreezeBegin)
{
if (Point.Length != PointGood) {
Vector3 a = Vector3.MoveTowards (transform.localPosition, Point [PointGood].transform.localPosition, Time.deltaTime * smooth);
transform.localPosition = a;
}
}
}
} else {
if (Point.Length != PointGood) {
if (transform.localPosition == Point [PointGood].transform.localPosition) {
PointGood++;
Freeze = 0;
}
if (Point.Length == PointGood) {
PointGood = 0;
Freeze = 0;
}
if (Freeze == FreezeBegin) {
if (Point.Length != PointGood) {
Vector3 a = Vector3.MoveTowards (transform.localPosition, Point [PointGood].transform.localPosition, Time.deltaTime * smooth);
transform.localPosition = a;
}
}
}
}
}
} else {
Freeze++;
}
}
}