Вопрос Срипт на Unity c# настройка персонажа (2D игра)

Регистрация
3 Авг 2013
Сообщения
94
Репутация
0
Спасибо
0
Монет
0
При нажатии на пробел персонаж прыгает, так и надо, но вот проблема в том что он еще не преземлился, а я снова нажимаю пробел и он опять прыгает и так далее
Вот скрипт
using UnityEngine;
using System.Collections;

public class hero : MonoBehaviour {
Rigidbody2D body;
public float speed = 3f;
public Vector3 startGame = new Vector3(-8, -4, 0);
public float jump = 15f;

// Use this for initialization
void Start () {
body = GetComponent();

}

// Update is called once per frame
void Update () {
Vector3 position = transform.position;

if (position.y < -5)
{
transform.position = startGame;
}
if (Input.GetKeyDown(KeyCode.Space))
body.AddForce(Vector2.up * jump, ForceMode2D.Impulse);

if (Input.GetKey(KeyCode.D))
{
transform.Translate(Vector2.right * speed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.A))
{
transform.Translate(Vector2.right * -speed * Time.deltaTime);
}
}
}
 
Назад
Сверху