-
Notifications
You must be signed in to change notification settings - Fork 0
/
FlightMechanic.cs
75 lines (64 loc) · 2.07 KB
/
FlightMechanic.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
65
66
67
68
69
70
71
72
73
74
75
namespace PathCreation.Examples
{
public class FlightMechanic : MonoBehaviour
{
public PathCreator pathCreator;
public PathCreator pesawatParkirOut;
public PathCreator pesawatParkirIn;
public PathCreator pesawatTakeOff;
public PathCreator pesawatLanding;
public GameObject kameraSatu;
public GameObject kameraDua;
public GameObject ParkirGaruda;
public GameObject CameraPesawatGaruda;
[SerializeField]
Camera onCameraGaruda;
public EndOfPathInstruction endOfPathInstruction;
public float speed = 5;
float distanceTravelled;
void Start() {
if (pathCreator != null)
{
pathCreator.pathUpdated += OnPathChanged;
}
}
void Update()
{
if (pathCreator != null)
{
distanceTravelled += speed * Time.deltaTime;
transform.position = pathCreator.path.GetPointAtDistance(distanceTravelled, endOfPathInstruction);
transform.rotation = pathCreator.path.GetRotationAtDistance(distanceTravelled, endOfPathInstruction);
}
}
void OnPathChanged() {
distanceTravelled = pathCreator.path.GetClosestDistanceAlongPath(transform.position);
}
public void berhenti()
{
speed = 0;
}
public void kurangKecepatan()
{
speed = speed-1;
}
public void tambahKecepatan()
{
speed = speed + 2;
}
public void parkirOut()
{
distanceTravelled = 0;
pathCreator = pesawatParkirOut;
}
public void takeOff()
{
speed = 1;
distanceTravelled = 0;
pathCreator = pesawatTakeOff;
kameraSatu.SetActive(false);
kameraDua.SetActive(true);
onCameraGaruda.GetComponent<Camera>().enabled = true;
}
}
}