我正在尝试使我的角色跳跃,但角色在按下跳跃按钮之前向上移动。它也不会回来,只是漂流而去。
using UnityEngine;
using System.Collections;
public class Movement : MonoBehaviour {
public float speed;
void Update () {
if (Input.GetKeyDown("space")) {
rigidbody.AddForce (Vector3.up * 10);
Debug.Log("Space has been pressed");
}
}
void FixedUpdate () {
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rigidbody.AddForce(movement * speed * Time.deltaTime);
rigidbody.AddForce (Vector3.up * 10);
}
}
}发布于 2014-11-22 23:51:47
在你的修复更新中,你已经告诉它将你的角色上移到AddForce。我想你的意思是说* -10而不是* 10 (我假设这是你手动应用重力),或者也许你根本不想把那条线放在那里?
https://stackoverflow.com/questions/27078784
复制相似问题