Hi,
I’m trying to make a figure moving like following ways:
-frist: move forward
-then: stand for 3 seconds
-and then: move forward again
My code:
using UnityEngine;
using System.Collections;
public class Citizen : MonoBehaviour {
public float speed_c = 0.5f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float amtToMove = speed_c * Time.deltaTime;
transform.Translate(Vector3.forward * amtToMove, Space.World);
}
void OnTriggerEnter(Collider item)
{
float amtToMove = speed_c * Time.deltaTime;
if (item.tag == "citizen_wall")
{
speed_c = 0;
StartCoroutine(Standing());
transform.Translate(Vector3.forward * amtToMove, Space.World);
}
}
IEnumerator Standing()
{
yield return new WaitForSeconds(3.0f);
yield return 0;
}
}
What happens:
The figure moves forward to the triggerbox. Then it stands there forever.
Could anyone give me some hints?
greetz
UfoHunter