Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

how to do that a objetct moves in c#

using System.Collections;  
using System.Collections.Generic;  
using UnityEngine;  
  
public class move : MonoBehaviour {  
  
    // Use this for initialization  
    void Start () {  
          
    }  
      
    // Update is called once per frame  
    void Update () {  
        if (Input.GetKey (KeyCode.W)) {  
            transform.Translate (0.05f, 0f, 0f);      
        }  
        if (Input.GetKey (KeyCode.S)) {  
            transform.Translate (-0.05f, 0f, 0f);      
        }  
        if (Input.GetKey (KeyCode.D)) {  
            transform.Translate (0.0f, 0f, -0.05f);      
        }  
        if (Input.GetKey (KeyCode.A)) {  
            transform.Translate (0.0f, 0f, 0.05f);      
        }  
    }  
  
}
 
PREVIOUS NEXT
Tagged: #objetct #moves
ADD COMMENT
Topic
Name
1+9 =