0
我正在做一個與Unity的android遊戲,我不知道如何做或多或少跳轉,取決於你按了多長時間的屏幕,我試過了,但我不知道該怎麼做,我使用deltatime,但它不起作用,至少沒有,至少不以我做的方式,所以我想知道如何做到這一點。角色跳躍,但只是一點點,不管我按了多少時間屏幕,它跳得這麼低。如何根據您在Android(c#)中按多長時間按屏幕來更多或更少地跳轉?
這是怎麼了,我想實現這一目標:
void Update() {
movimiento();
if (transform.position.x <= 4.65f) {
SceneManager.LoadScene ("Game Over");
}
if (Input.touchCount > 0) {
GetComponent<Animator>().Play ("Andar 2");
print (Input.GetTouch (0).deltaTime);
if (Input.GetTouch (0).deltaTime >= 2) {
GetComponent<Rigidbody2D>().AddForce (Vector3.up * Time.deltaTime * 20000);
GetComponent<Animator>().Play ("Andar 2");
} else if (Input.GetTouch (0).deltaTime >= 1) {
GetComponent<Rigidbody2D>().AddForce (Vector3.up * Time.deltaTime * 2000);
} else if (Input.GetTouch (0).deltaTime < 1) {
GetComponent<Rigidbody2D>().AddForce (Vector3.up * Time.deltaTime * 200);
}
}
}