Can't seem to do this. I get and error saying ' Update() can not take parameters.' This means there's something very wrong with my understanding!
I want to attach a behaviour (in game) to an object. Perhaps a behaviour that makes it transform in the x axis continuously by a certain amount.
This amount will not be definite, it will be decided in game. So I need to pass this parameter to the update script while the game runs.
I want to do something like:
// in another script
var thing = Instantiate(myObject, transform.position, transform.rotation);
var howMuchToMove = 12;
//add the script to the object and pass a variable
thing.AddComponent(moveInX(howMuchToMove));
//in the moveInX script that will be attached to the object
function Update(howMuchToMove) {
//move continuously by an an amount defined elsewhere
transform.position = Vector3(howMuchToMove, 0, 0);
}
I get and error saying 'Update() can not take parameters.' I can see a problem here; that update will always be checking for the parameter when really that only needs to happen once, but I don't see any other way of getting a variable to it.