Greetings
So I want to instantiate an object after a certain time (4 seconds) and the code runs fine, no errors appear and I can execute the game but no object instantiates after the 4 seconds?
Here's my code:
` using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public GameObject EnemyFab;
float gameClock;
void Update ()
{
gameClock = Time.time;
if (gameClock == 4.0f)
{
Debug.Log("yo");
Vector3 position = new Vector3(Random.Range(-5, 5), 11, 0);
Instantiate(EnemyFab, position, Quaternion.identity);
}
}
}
`
I know there is a couple of unnecessary things in there but I've been trying everything I could think of to make the Enemy Instantiate. By the way I am not getting any yo's in the debug. I'd be grateful for any help or suggestions!
EDIT: Also I had another question; So instead of destroying my object after it collides with an enemy I set `renderer.enabled = false;` and then a couple of seconds later it reapers when I set `renderer.enabled = true;` but all that time is isn't rendered its still physically has a collier and a transform and can still collide with objects. So I would prefer a ?Function?Code?Method?(don't even know what to call it :| ) instead of `renderer.enabled` that will physically move it or disable it for a certain amount of time?
Thank you very much for your time :)
↧