-
Notifications
You must be signed in to change notification settings - Fork 0
/
MoveForward.cs
35 lines (31 loc) · 933 Bytes
/
MoveForward.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
using UnityEngine;
using System.Collections;
public class MoveForward : MonoBehaviour {
public float speed = 2f;
public static bool stop = false;
public static bool back = false;
public static bool slow = false;
void Start () {
}
void Update () {
if (!stop)
{
if (!slow && !back)
{
transform.position += Vector3.right * speed * Time.deltaTime;
}
else if (slow && !back)
{
transform.position += (Vector3.right * speed * Time.deltaTime) / 4;
}
else if (!slow && back)
{
transform.position -= Vector3.right * speed * Time.deltaTime;
}
else if (slow && back)
{
transform.position -= (Vector3.right * speed * Time.deltaTime) / 4;
}
}
}
}