Я играю в лабиринт в Unity и хочу, чтобы персонаж был направлен на клавиатуру стрелки на клавиатуре, «когда игрок нажимает вправо, персонаж должен быть направлен вправо»
Вот что я получил до сих пор:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MovimentoBola : MonoBehaviour
{
public float speed = 10.0f;
public float rotationSpeed = 100.0f;
public GameObject skull;
float posx, posy;
float rotx, roty, rotz;
void Start()
{
posx = Time.deltaTime * speed;
posy = Time.deltaTime * speed;
rotz = skull.transform.rotation.z;
}
void Update()
{
if (Input.GetKey(KeyCode.UpArrow)) //Seta pra cima
{
transform.Translate(new Vector3(0, posy));
}
if (Input.GetKey(KeyCode.DownArrow)) //Seta pra baixo
{
transform.Translate(new Vector3(0, -posy));
}
if (Input.GetKey(KeyCode.RightArrow)) //Seta pra direita
{
transform.Translate(new Vector3(posx, 0));
rotz += 90;
}
if (Input.GetKey(KeyCode.LeftArrow)) //Seta pra esquerdas
{
transform.Translate(new Vector3(-posx, 0));
}
}
}