- Home /
Question by
Casey28xxx · May 07, 2013 at 08:28 PM ·
noobcompatibility
Particle effect instantiate problem.
//Enemy Script
//Inspector variables
var numberOfClicks : int =2; //no of times you click to destroy object
var respawnWaitTime : float =2.0;
var shapeColour :Color[]; //colour array
var explosion :Transform; //loads the particle effect
var enemyPoints : int =1; // value of enemy destroyed
//Private variables
private var storeClicks : int =0;
function start()
{
storeClicks = numberOfClicks;
}
function Update ()
{
if(numberOfClicks <=0)
{
if(explosion)
{
Instantiate (explosion, transform.position, transform.rotation); //create an explosion
}
var position = Vector3 (Random.Range(-6,6),Random.Range(-4,4),0); //new random position for game objects
RespawnWaitTime ();
transform.position = position; //move game object to new position
numberOfClicks =storeClicks;
}
}
// will be used to hide and then unhide a GO for a random amount of time
function RespawnWaitTime ()
{
renderer.enabled =false;
RandomColour();
yield WaitForSeconds (respawnWaitTime);
renderer.enabled =true;
}
// random colour is used to change the colour of enemy GO in game
function RandomColour ()
{
if(shapeColour.length >0)
{
var newColour = Random.Range(0,shapeColour.length);
renderer.material.color =shapeColour[newColour];
}
}
Been following the Walker Boys tutorial for a basic clicking game, everything seemed to be going smoothly until I got to adding lines of code for creating a scoring system. Could this be an issue with using unity 4 and the tutorials being 2 years old? Or is it just me and my lack of understanding?
Any help appreciated as always.
Comment
SOLVED!
//Private variables
private var storeClicks : int =2;
I changed this to 2 even though in the tutorial video it's set to 0! Yet still gives the same result of working??
I'm still convinced something is wrong here and would love to get to the bottom of it.
Best Answer
Answer by Casey28xxx · May 13, 2013 at 11:45 PM
Sorted.
Grammar as usual "function Start" instead of "function start"!
Your answer
Follow this Question
Related Questions
Noob question - why isn't my emissive surfacce working? 2 Answers
Unity 5 Networking Help 0 Answers
How to set up a cave in Unity ? 2 Answers
Enemy won't damage player C# 1 Answer
Help fixing a bug with camera script 2 Answers