2015-08-26 28 views
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); 

     } 
    } 
} 

回答

1

你都清楚地翻动周围transform.eulerAngles = new Vector2(0, 180);

精灵不应该有必要对y轴旋转的精灵。您要么旋转z轴,要么不需要。

+0

我的游戏是2D游戏,所以我怎样才能改变我的玩家的精灵和/或方向而不改变它? –

+0

我想你打算在另一个轴上旋转它? 'y'轴的旋转不符合渲染的视图。 – maksymiuk

+0

@Andrew也许António不知道如何绕其他轴旋转。包括一个使用'Vector3'围绕Z旋转的例子会很有帮助。 – 31eee384

相关问题