Generation

generate functionSun, 23 Jul 2023

Un script adentro de unity que mueva al personaje con W hacia arriba, S hacia abajo, D hacia la derecha y A hacia la izquierda en un juego 3D, moviendose sobre los ejes X y Z segun el delta time y que el personaje rote en el eje Y para siempre mirar en la direccion en la que esta caminando

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Moverse : MonoBehaviour { float x = 0f; float y = 0f; float z = 0f; float rotateY = 0f; float translate = 1f; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (Input.GetKey(KeyCode.W)) { z = z + Time.deltaTime * translate; } if (Input.GetKey(KeyCode.S)) { z = z - Time.deltaTime * translate; } if (Input.GetKey(KeyCode.D)) { x = x + Time.deltaTime * translate; } if (Input.GetKey(KeyCode.A)) { x = x - Time.deltaTime * translate

Questions about programming?Chat with your personal AI assistant