help in assecing variable

Please help me figure out how to change a variable from another object.
The Player object has a public float named “size”, and the Circle object has a public float named “size”.I want to be able to increase size from the Circle, but I can’t. The code is as follows:
The code is as follows:
Collision2D collisionEnter2D(void)
{i
“Player” if (coll.gameObject.name)
{
The size of this.GetComponent*playerMovement>() is equal to 1;
}
}
I get a nullreferenceexception error whenever I run this code. Since I have no idea what code is, I would appreciate a brief explanation of Unity and C#.

Hmm, if you have no idea what code is, then you are getting ahead of yourself. You will not be able to successfully create games in Unity without a basic understanding of C#.

Google “C# beginner tutorial” and plan to spend a few weeks going through the tutorials you find. https://www.learncs.org/ is a decent place to start, too.

1 Like

The code as posted will not compile, as it is not C# syntax. You should be getting compile errors in the console. As already mentioned, start with some C# tutorials. People on the forum can help with specific questions, but can’t teach such a large topic in a single post. There’s good reason a book to teach you C# will be several hundred pages.