Help!! Am I dumb or something?!

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)

please!

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.

–Eric

Thx for your reply Eric.
But I’ll try to be more specific,

In this script that I made and is attached to the gameobject, there’s a var called “active”, and its defaut property is “false”

I want to know, how, via another script, I can make it “true” ^^
*WHILE i’m in-game
Got it?

Take a look at this page:

Pretty much the exact example you need.

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.

Sorry, but I really don’t get it :confused:
I didn’t understand how to “reference” the script.
Plus, the var that is going to be altered needs to be private?

Mr. Gerald posted a link to a good video tutorial series for beginners.

We could try our best to explain how things work, but often video tutorials do a better job.

I would urge you to watch through them all, since it is advised to have at least basic programming knowledge. Best of luck!

Also, there are about a million questions/answers about using GetComponent, so a search will get plenty of relevant results.

–Eric

Sounds like you need to do a bunch of basic scripting tutorials.

Check the learn section at the top of the page