1
我在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);
}
}
}
我的游戏是2D游戏,所以我怎样才能改变我的玩家的精灵和/或方向而不改变它? –
我想你打算在另一个轴上旋转它? 'y'轴的旋转不符合渲染的视图。 – maksymiuk
@Andrew也许António不知道如何绕其他轴旋转。包括一个使用'Vector3'围绕Z旋转的例子会很有帮助。 – 31eee384