Код: Выделить всё
using UnityEngine;
public class Player : MonoBehaviour
{
// The force which is added when the player jumps
// This can be changed in the Inspector window
public Vector2 jumpForce = new Vector2(0, 300);
// Update is called once per frame
void Update ()
{
// Jump
if (Input.GetKeyUp("space"))
{
rigidbody2D.velocity = Vector2.zero;
rigidbody2D.AddForce(jumpForce);
}
}
}
Теперь я хочу, чтобы это было, когда я нажимаю стрелку вправо клавиша, объект переместится вправо, я так и сделал:
Код: Выделить всё
using UnityEngine;
public class Player : MonoBehaviour
{
void Update ()
{
if (Input.GetKey(KeyCode.UpArrow)) {
transform.Translate(Vector3.forward * Time.deltaTime);
}
}
Подробнее здесь: https://stackoverflow.com/questions/252 ... -key-right