Input.getaxis возвращает -1 по умолчанию Unity 5.3.0C#

Место общения программистов C#
Ответить
Anonymous
 Input.getaxis возвращает -1 по умолчанию Unity 5.3.0

Сообщение Anonymous »

Код: Выделить всё

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {

public float speed = 8.0f;
public float maxVelocity =3.0f;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

float force = 0.0f;
float velocity = Mathf.Abs (GetComponent().velocity.x);

float h = Input.GetAxis ("Horizontal"); //getting input along x-axis only

Debug.Log (h);

if (h > 0) {
if (velocity < maxVelocity) {
force = speed;
}
Vector3 scale = transform.localScale;
scale.x = 1;
transform.localScale = scale;

} else if (h < 0) {

if (velocity < maxVelocity) {
force = -speed;
}

Vector3 scale = transform.localScale;
scale.x = -1;
transform.localScale = scale;
}

GetComponent().AddForce (new Vector2 (force, 0));

}
}
Здесь мое значение h всегда возвращает -1, даже если я не нажимаю ни одну из клавиш вправо/влево.

Может ли кто-нибудь указать здесь мою проблему?

Подробнее здесь: https://stackoverflow.com/questions/343 ... nity-5-3-0
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»