Answers for "how to move a gameobject"

C#
2

how to move a gameobject

public static int movespeed = 3;
   public Vector3 userDirection = Vector3.down; //You can change this to any direction
   
   void Update()
    {
        transform.Translate(userDirection * movespeed * Time.deltaTime);
    }
Posted by: Guest on February-23-2021
2

how to move a gameobject to another object

//Attach this to the oject you want to move
public GameObject Bullet
public GameObject Cannon

void Start()
{
 (Bullet) = GameObject.Find("Bullet"); //These are to find the object to move to
 (Cannon) = GameObject.Find("Cannon"); 
 Bullet.transform.position = Cannon.transform.position; //this is to move the object
}
Posted by: Guest on February-22-2021

Code answers related to "how to move a gameobject"

C# Answers by Framework

Browse Popular Code Answers by Language