This is not pausing the entire game, only an aspect of an enemy
Ok, what I’m looking for is my ‘enemy’ to pause his respawn for X amount of time after he collides with my player.
I have already tried to utilize “yield waitforseconds” code but I’m not looking for a delay because the enemy has other respawns as well. I just want him to pause his respawn AFTER he collides with the player for X amount of time.
`
using UnityEngine;
using System.Collections;
public class Blocker : MonoBehaviour
{
#region Variables
public float MinSpeed;
public float MaxSpeed;
public float currentSpeed;
private float x, y, z;
#endregion
#region Properties
#endregion
#region Functions
void Start()
{
SetPositionAndSpeed();
}
void Update()
{
float amtToMove = currentSpeed * Time.deltaTime;
transform.Translate(Vector3.down * amtToMove);
if (transform.position.y <= -5)
{
SetPositionAndSpeed();
}
}
public void SetPositionAndSpeed()
{
currentSpeed = Random.RandomRange(MinSpeed, MaxSpeed);
x = Random.RandomRange(-3.7f, 4.1f);
y = 8.0f;
z = 0.0f;
transform.position = new Vector3(x, y, z);
}
void OnTriggerEnter(Collider otherObject)
{
//if blocker hits the player, delay the blocker's spawn
if (otherObject.tag == "player")
{
Player player = (Player)otherObject.gameObject.GetComponent("player");
//Pause for 1.5 seconds;
}
}
#endregion
}
`