Hi Im currently stuck at classes I watched numerous tutorials about classes I got the but I dont seem to get their usage.
I have object spawning obstacles, spawners code is
function Update ()
{
time -= Time.deltaTime;
if(time <= 0)
{
var cube : GameObject = spawnPoints[Random.Range(1,6)];
var currentObstacle : GameObject = GameObject.Instantiate(obj2, cube.transform.position - Vector3(0,0.5,0), cube.transform.rotation);
currentObstacle.AddComponent("scriptObstacleCube");
currentObstacle.Spawn(1); //I wanted to give this object basic parameters by class but it doesnt work.
currentObstacle.GetComponent(scriptObstacleCube).speed = currentSpeed;
time = frequency;
}
}
and spawned object has basic class:
public class Spawn {
public var number : int;
function Spawn(number : int)
{
this.number = number;
}
}
public var test : Spawn = new Spawn(5);
Ok, now the problem is I want spawner to create obstacle and give it basic parameters using class. However I see I could just use regular function instead of class. I need explaination how to use class to instantiate objects etc, tutorials I saw are not about usage in object operations, and where should I declare class? (in spawner or in the spawned object)
If something is unclear Ill clarify.