Answers for "how to do that a objetct moves in c#"

C#
0

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);      
        }  
    }  
  
}
Posted by: Guest on April-19-2022

Code answers related to "how to do that a objetct moves in c#"

C# Answers by Framework

Browse Popular Code Answers by Language