-
Notifications
You must be signed in to change notification settings - Fork 0
/
dichuyen.txt
169 lines (132 loc) · 3.57 KB
/
dichuyen.txt
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//di chuyen cua dong vat
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class fox : MonoBehaviour
{
static Animation ani;
public Transform[] path;
public float speed = 1.0f;
public float reach = 1.8f;
public int poit = 0;
AudioSource a1;
AudioSource a2;
public Transform b;
public AudioClip s1;
public AudioClip s2;
void aw()
{
a1 = gameObject.AddComponent<AudioSource>();
a1.loop = true;
a1.clip = s1;
a1.volume = 0.1f;
a1.maxDistance = 70.0f;
a1.pitch = Random.Range(0.5f, 1.5f);
a1.playOnAwake = false;
a1.mute = true;
a1.Play();
a2 = gameObject.AddComponent<AudioSource>();
a2.loop = true;
a2.mute = true;
a2.clip = s2;
a2.volume = 0.4f;
a2.maxDistance = 70.0f;
a2.playOnAwake = false;
a2.pitch = Random.Range(-1, 2);
a2.Play();
}
void Start()
{
aw();
ani = GetComponent<Animation>();
}
void Update()
{
interac();
}
void dis()
{
ani.Play("run");
float dist = Vector3.Distance(path[poit].position, transform.position);
transform.LookAt(path[poit].position);
transform.Translate(Vector3.forward * speed * Time.deltaTime * 0.5f);
if (dist <= reach)
{
poit=poit+1;
if (poit >= path.Length)
{
poit = 0;
}
}
}
float distance;
void interac()
{
distance = Vector3.Distance(b.position, transform.position);
if (distance > 40.0f)
{
a1.mute = false;
dis();
}
if (distance <= 40.0f && distance >=20.0f)
{
a2.mute = false;
transform.LookAt(b.position);
ani.Play("bite");
}
if (distance <= 20.0f)
{
a1.mute = false;
transform.LookAt(-b.position);
ani.Play("run");
}
if (distance > 50.0f) a2.mute = true;
if (distance > 90.0f) a1.mute = true;
}
}
//di chuen cua play
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ch : MonoBehaviour {
public Transform Camera;
public float tog = 30.0f;
public float speed = 3.0f;
public bool move;
private CharacterController cc;
AudioSource b1;
AudioSource b2;
public AudioClip s;
// Use this for initialization
void Start () {
cc = GetComponent<CharacterController>();
ae();
}
void ae()
{
b1 = gameObject.AddComponent<AudioSource>();
b1.loop = true;
b1.clip = s;
b1.volume = 0.1f;
b1.maxDistance = 70.0f;
b1.pitch = 0.7f;
b1.playOnAwake = false;
b1.mute = true;
b1.Play();
}
// Update is called once per frame
void Update () {
if (Camera.eulerAngles.x >= tog && Camera.eulerAngles.x < 90.0f)
{
move = true;
}
else move = false;
if (move)
{
Vector3 forward = Camera.TransformDirection(Vector3.forward);
cc.SimpleMove(forward * speed);
}
if (move) b1.mute = false;
if(!move) b1.mute =true;
}
}