Why isn't transform.position.Set working?

I am not new to programming or even video game development, but I am very new to Unity, and this one currently has me stumped.

I am following the Space Shooter guide, and currently have a single GameObject in my PlayerController class

public GameObject blastObjTemplate;
    private GameObject blastObj;

    void Awake()
    {
        blastObj = Instantiate(blastObjTemplate, transform.position, transform.rotation) as GameObject;
        blastObj.SetActive(false);
    }

I then want to have that object appear at the same point as the player after hitting the attack button, so I do this:

        blastObj.SetActive(true);
        blastObj.transform.position.Set(transform.position.x, transform.position.y, transform.position.z);

But blastObj remains at origin. After debugging the code, I can see that the values for transform.position are as expected, but blastObj.transform.position remains the same after Set. What gives?

Some one wrote a workaround here: GameObject position.Set() not working - Questions & Answers - Unity Discussions

Maybe this will help?

Okay, that worked. Thanks! Didn’t realize that transform.position returned a copy.

1 Like