Translate another GameObject

Hi ! ^^

I am new on Unity and I am french so i beg your pardon for my easy question or english mistakes :wink:

So, this is my question :

I have found how to translate a game object with the command “transform.Translate” but I want to translate another gameObject which is not attached to the script which contains the translate command.

For example, when the mouse is over the gameObject n°1 which is attached to the script, I want gameObject n°2 translates.

A great thank to persons who will take a little of their time to answer me ^^

Hey.

Are you using this already : ? Unity - Scripting API: MonoBehaviour.OnMouseOver()

In the script that is in GameObject#1 you can add field with “public GameObject gameObject2” and assign there the GameObject#2

Then in your OnMouseOver function you can do “gameObject2.transform.Translate…”

Yes, i am using OnMouseOver ^^

Yes, it works perfectly ! ^^
It looks like so simple when we understand how it works ^^

Great thanks guillermoi ! :slight_smile: