Answers for "unity move object from another script"

C#
1

unity how to move an object to another object

// 3D
transform.position = new Vector3(GameObject.Find("Object").transform.position.x, GameObject.Find("Object").transform.position.y, GameObject.Find("Object").transform.position.z);

// 2D
transform.position = new Vector2(GameObject.Find("Object").transform.position.x, GameObject.Find("Object").transform.position.y);
Posted by: Guest on February-12-2020
1

unity move object from another script

// Moving a list of objects down on key press
public GameObject[] deck;
public float movementSpeed = 30;

void Update()
    {
        if (Input.GetKey(KeyCode.E))
        {
            foreach (var obj in deck) 
            {
                obj.transform.Translate(Vector3.down * movementSpeed * Time.deltaTime);
            }
        }
    }
Posted by: Guest on June-12-2021

Code answers related to "unity move object from another script"

C# Answers by Framework

Browse Popular Code Answers by Language