This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
public-speaking-vr/Assets/Scripts/WalkOut.cs
2016-11-19 13:14:49 -06:00

49 lines
1.1 KiB
C#

using UnityEngine;
using System.Collections;
using UnityStandardAssets.Utility;
public class WalkOut : MonoBehaviour {
Animator anim;
bool changeDir = false;
// Use this for initialization
void Start()
{
anim = gameObject.GetComponent<Animator>();
StartCoroutine("Wait");
}
// Update is called once per frame
void Update()
{
if (anim.GetBool("Walk"))
{
gameObject.GetComponent<AutoMoveAndRotate>().SetMoveSpeed(new Vector3(0, 0, 1));
if (!changeDir)
gameObject.GetComponent<AutoMoveAndRotate>().SetRotateSpeed(new Vector3(0, -15, 0));
}
}
IEnumerator Wait()
{
yield return new WaitForSeconds(60);
anim.SetBool("Walk", true);
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "ChangeDir")
{
gameObject.GetComponent<AutoMoveAndRotate>().SetRotateSpeed(new Vector3(0, 0, 0));
changeDir = true;
}
if (other.tag == "Door")
{
Destroy(gameObject);
}
}
}