Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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);
    }
Comment

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
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to play animation with code in unity 
Csharp :: how to get the position of a camera in unity 
Csharp :: c# how do you check if a string contains only digits 
Csharp :: start command line from c# 
Csharp :: getname of month from date c# 
Csharp :: merge point 
Csharp :: consecutive numbers c# 
Csharp :: Comapre Binary Trees 
Csharp :: SAVE FLOAT UNITY 
Csharp :: c# list index 
Csharp :: tinyint in c# 
Csharp :: create char array c# 
Csharp :: unity how to load a scene 
Csharp :: c# groupby date 
Csharp :: write text files with C# 
Csharp :: c# find duplicates in list of strings 
Csharp :: unity 2d player move 
Csharp :: c# get value from textbox 
Csharp :: unity c# 
Csharp :: unity assembly 
Csharp :: excel which style property define background color in c# 
Csharp :: smtp check if email sent 
Csharp :: how to clone something unity 
Csharp :: check if animation is playing unity 
Csharp :: c# loop string array 
Csharp :: getting the row of max value c# linq 
Csharp :: c# distinct by property 
Csharp :: c# move files from one directory to another 
Csharp :: list index out of range c# 
Csharp :: c# byte 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =