[Solved]Can't change variable values on Instantiated object

Hi, I’ll start with an example

OtherClassName Go = Instantiate(gameobject, transform.position, Quaternion.identity) as OtherClassName;
Go.variableOne = 10; //This line isn’t read
Debug.Log(“Passed here”); //neither is this one

Despite variableOne auto completing, or using GetComponent or trying to pass as a paramenter in a function
I can never change/set a value in one object I just instantiated.
And it happens in any project no matter how many ways I try to change the code. Even if I copy paste from the manual.
I’ve even reinstaled Unity, updated drivers, increased swap memory, disabled mcafee(cause of internal compiiler error);
This problem got me stuck in my college project and I don’t know what else to try, sugestions?

public class FrameTimer : MonoBehaviour
{
  public Transform prefab;
  public float Variable;

  internal void SomeMethod()
  {
    var Go = Instantiate(this.prefab, transform.position, Quaternion.identity) as GameObject;
    var Comp = Go.GetComponent<FrameTimer>();

    Comp.Variable = 10; //This line isn't read
    Debug.Log("fooohaari"); //neither is this one
  }

*snip*

assign a prefab of the object to the Transform prefab field
also make sure to have watched all tutorials here: Learn

1 Like

Thank you reallly really much it worked,
I didn’t know about var the problem was there.