-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutowalk.cs
44 lines (30 loc) · 835 Bytes
/
Autowalk.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class Autowalk : MonoBehaviour
{
public static float speed ;
public static bool moveforward;
private CharacterController controller;
private Transform vrHead;
void Start()
{
controller = GetComponent<CharacterController>();
vrHead = Camera.main.transform;
}
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
moveforward = !moveforward;
}
if (moveforward)
{
speed = 1.0f;
Vector3 forward = vrHead.TransformDirection(Vector3.forward);
controller.SimpleMove(forward * speed);
}
}
}