blob: b167832e8d8874543ef96a40c08d67091bc78b51 (
plain)
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
|
using UnityEngine;
public class Zop : MonoBehaviour
{
public float turn = 0.2f;
private float count;
private int sinceSwitch = 1;
private bool up;
private MoveTransform move;
public bool randomZop;
private void Start()
{
move = GetComponentInParent<MoveTransform>();
if (base.transform.forward.x < 0f)
{
up = true;
}
}
private void Update()
{
count += TimeHandler.deltaTime;
if (!(count > turn))
{
return;
}
if (up)
{
move.velocity = move.velocity.magnitude * Vector3.Cross(base.transform.forward, Vector3.forward);
}
else
{
move.velocity = move.velocity.magnitude * -Vector3.Cross(base.transform.forward, Vector3.forward);
}
count = 0f;
if (!randomZop || !(Random.value > 0.8f))
{
sinceSwitch++;
if (sinceSwitch == 2)
{
up = !up;
sinceSwitch = 0;
}
}
}
}
|