我的玩家在后退时消失
本文关键字:消失 玩家 我的 | 更新日期: 2023-09-27 18:10:07
我正在用Unity 5"玩"游戏,在我的游戏中,当我移动5 X个单位时,我的玩家精灵就消失了。我将把我的动作脚本放在下面,如果你需要更多的信息来帮助我,请问。
public class Player : MonoBehaviour {
public float speed;
public float forcaPulo; //means jump
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Movimentacao(); // means movement
}
void Movimentacao() {
if (Input.GetAxisRaw ("Horizontal") > 0) {
transform.Translate (Vector2.right * speed * Time.deltaTime);
transform.eulerAngles = new Vector2(0, 0);
}
if (Input.GetAxisRaw ("Horizontal") < 0) {
transform.Translate (Vector2.right * speed * Time.deltaTime);
transform.eulerAngles = new Vector2(0, 180);
}
if (Input.GetButtonDown("Jump")) {
GetComponent<Rigidbody2D>().AddForce(transform.up * forcaPulo);
}
}
}
你显然是在围绕transform.eulerAngles = new Vector2(0, 180);
翻转精灵
不需要在y
轴上旋转精灵。
z
轴或它不需要。