For some reason I'm having substantial problems simply instantiating a GameObject of a certain type, and then making it perform actions. I think the problem is that I'm missing some kind of underlying fundamentals on how Unity behaves.
I have a GUI button, when clicked it calls the ButtonPressed_Green() function on the target, the target being an instance of the character in game.
function ButtonPressed_Green()
{
var blob = Instantiate(blobFab, Vector3(transform.position.x, transform.position.y+5, transform.position.z), Quaternion.identity);
blob.movement.direction.x = 1;
blob.SendMessage("ToggleWalking");
}
This code should create an instance of blobFab, a variable on my script that is set to the prefab BlobParent. It does that part fine, but the second line "blob.movement.direction.x" does not work.
Movement is a variable of the BlobController script (this same script, this blob is essentially duplicating itself) that refers to the BlobMovement class with some variables for x/y/z. How do I access these variables using the GameObject reference, blob, itself?