Trying to move a gameobject using another gameobjects position

Hi, i am trying to move my gameobject “Wall” to "GhostWall"s position, but it is not working.

Here is my script:

public gameobject Wall;
public gameobject GhostWall;

public void start()
{
Instantiate(Wall, new Vector3(1001f, 226f, 720f), Quaternion.identity);
Wall2.position = new Transform(GhostWall2);
}

Thanks Nick

Try this

GameObject Wall2 = Instantiate(Wall, new Vector3(1001f, 226f, 720f), Quaternion.identity) as GameObject;
Wall2.transform.position = GhostWall2.transform.position;

Actually… let me try that again.

If you’re trying to make a copy of Wall and move it to GhostWall, try this:

GameObject Wall2 = Instantiate(Wall, new Vector3(1001f, 226f, 720f), Quaternion.identity) as GameObject;
Wall2.transform.position = GhostWall.transform.position;

If you just want to move the current Wall to GhostWall, try this:

Wall.transform.position = GhostWall.transform.position;

1 Like

Thankyou i will try that

Yes, thankyou that helped alot. :slight_smile: