Files
RatStabber/Assets/Scripts C#/Ratbots/Creeper.cs
2024-10-28 15:39:01 -07:00

22 lines
444 B
C#

using UnityEngine;
using System.Collections;
public class Creeper : Ratbot
{
float countdown;
void Update() {
if (Vector3.Distance(player.transform.position, transform.position) > 5) {
MoveTowardsPlayer(moveSpeed);
float newTime = countdown + Time.deltaTime;
countdown = (newTime < 1) ? newTime : 1;
} else {
countdown -= Time.deltaTime;
if (countdown < 0) Explode();
}
}
void Explode() {
Destroy(gameObject);
}
}