Problem to store a gameObject

Hi,
So, I’m instantiating a gameObject Model and I want it to follow my mousePos, but it just instantiates and isn’t following (it’s where “Follow mousePos”) I tried to use curObj or Model in that statement, but nothing happened. I also tried to use just transform.position and it was working, so I think the code is correct, but the problem is that I don’t know how to store this Model instantiation properly.

if (Model != null && ifBool)
        {
            Instantiate(curObj = Model, mousePos, transform.rotation);
            ifBool = false;
        }
        else if (Model != null)
        {
            curObj.transform.position = mousePos; // Follow mousePos
        }

So, do you know what is my mistake and how can I solve this?

Put “curObj =” before “Instantiate”.

1 Like

Ty, simple mistake :slight_smile: