Transform to game object

first sorry if my english is bad because im from germany

ok the problem

i mad an empty GameObject that is moving arround

now i have a gun that should be transform to the position of the Gameobject if i press a button

if(Input.GetButtonDown("Fire1"))

and now that the gun is transform to the gameobject(the gun is already part of the game object it moves with it at position y =-200 so very low under the scene if i just say t*ransform.position.y = 2* or something else there is the problem when the gameobject is moving up the gun is at the wrong place)

PS im very a beginner with scripting so i will be happy if somebody has a simple idee

Could you please provide more information about what you want. You explained that there are two game objects:

  1. A GO that holds the gun that is located -200 units below the floor
  2. An empty GO that moves around independently of the first

As far as I can tell you want the gun mesh to move to the same location as the empty GO whenever a button is clicked.

What is unclear is what the problem is. You mentioned that when one of the game objects (which one is not clear) moves, the gun is at the wrong place. How do you know it is at the wrong place? Where is it?

I think if you edit your question to provide more information and specifics about how it does work and how it should work, someone will be able to help you.

UPDATE

If all you need is for one GameObject to move to the location of another, then it should be pretty simple.

public var otherGo : GameObject;

function Update() {
    if(Input.GetButtonDown("Fire1")) {
        transform.position = otherGo.transform.position;
    }
}

ok i try

there is an empty GO

and its moving

up down left right and so on

now somwhere in the scene is an other object

now should this other object move to the empty GO

the problem is not important i need only a script that says that the other object moves to the emptY GO