Net_Ease_Dome/Assets/Scripts/AutoWalk.cs

25 lines
553 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AutoWalk : MonoBehaviour
{
float timer = 0;
float randomx, randomz;
// Update is called once per frame
void Update()
{
if (!GameManager.AutoWalk) return;
timer += Time.deltaTime;
if (timer > 1)
{
timer = 0;
randomx = (Random.value - 0.5f) * 5;
randomz = (Random.value - 0.5f) * 5;
transform.localEulerAngles = new Vector3 (0, Random.value*360, 0);
}
transform.Translate(new Vector3(randomx, 0, randomz) * Time.deltaTime);
}
}