Created
January 24, 2024 06:21
-
-
Save damiancastelao/c884c58b7fb175c1fc319ba867746374 to your computer and use it in GitHub Desktop.
Unity - Traslacion y Rotacion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class TransformFunctions : MonoBehaviour | |
{ | |
public float moveSpeed = 10f; | |
public float turnSpeed = 50f; | |
void Update () | |
{ | |
if(Input.GetKey(KeyCode.UpArrow)) | |
transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime); | |
if(Input.GetKey(KeyCode.DownArrow)) | |
transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime); | |
if(Input.GetKey(KeyCode.LeftArrow)) | |
transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime); | |
if(Input.GetKey(KeyCode.RightArrow)) | |
transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Si le aplicamos este script a un objeto, lo podremos trasladar en dirección Z y rotar en la direccion del eje Y