Answers for "connect with my chase code"

0

connect with my chase code

public class Petrol : MonoBehaviour
{
    public float speed;
    private float waitTime;
    public float startWaitTime;

    public Transform[] moveSpots;
    private int randomSpot;

    void Start()
	{
        waitTime = startWaitTime;
        randomSpot = Random.Range(0, moveSpots.Length);
	}

    void Update()
    {
        transform.position = Vector3.MoveTowards(transform.position, moveSpots[randomSpot].position, speed * Time.deltaTime);

        if (Vector3.Distance(transform.position, moveSpots[randomSpot].position) < 0.2f)
		{
            if(waitTime <= 0)
			{
                randomSpot = Random.Range(0, moveSpots.Length);
                waitTime = startWaitTime;
			} else
			{
                waitTime -= Time.deltaTime;
			}
		}
    }
}
Posted by: Guest on February-06-2020

Code answers related to "connect with my chase code"

Browse Popular Code Answers by Language