Hey everyone… I’M PISSED OFF cause I’m new at coding and I cannot do a simple task.
Ok, lets go, I have a var with an undefined (yet) GameObject. Okay. We shall drag the gameobject to the var on the inspector.
Okay, this GameObject has a script attached with the value “x”. I would like to know how, based on the gameobject that was dragged into the slot, I could change the value “x” via script.
WRONG EXAMPLE, JUST FOR COMPREHENSION
var buceta : GameObject;
buceta.x = wishedvalue
Do you get it? I want to change this X value via a script that is NOT attached to this gameobject, but with something else (like a trigger activation, in my case)
GameObjects don’t have any “x” value. I assume you’re talking about the position, which is a property of the Transform component attached to the GameObject. So it would be buceta.transform.position.x.
The gist of it is that you need to reference your script on that object, and then you can access its properties. You’re trying to access those properties through the GameObject which isn’t your script.