2017-02-15 23 views
-2

我已經獲得了基本的運動:左,右,跳。使用GetKeyDown/Up。加入速度的超級馬里奧運動Unity2D

我需要玩家運行聯合2按下不同的按鈕。

By:按住按鈕並按下右鍵以加快玩家的正確方向。

我需要你的幫助

+1

請發表您已經嘗試了什麼。 StackOverflow不是代碼寫入服務。 –

+0

謝謝,我得到了新的東西,必須瞭解Input.GetAxisRaw – Ricardo

回答

1
speed = Input.GetAxisRaw("Horizontal") * 5; //or whatever value 
if(Input.GetKeyDown(keycode.shift) 
{ 
    speedmodifier = 5f; //or whatever value 
} 
else speedmodifier = 1f; 
GetComponent<Rigidbody2D>().velocity = new Vector2(speed*speedmodifier, GetComponent<Rigidbody2D>().velocity.y); 
+0

如果你喜歡這個答案,請記得檢查按鈕,說接受這個答案。 –