C
C#11mo ago
prinzbartu

Getting a specific player input inbetween a specific time interval

Hi. Im currently trying to code a Volleyball game in unity. I have done basic movement and also the field setup, (its 2d) but what I dont manage is that I want the player to have to press specific button-combos in order to perform specific volleyball moves. So in this example, I want the player to first click "Q" and then choose one of WASD to choose what side hes gonna set the ball to. This is my code: private void Setting() { if (Input.GetKeyDown(KeyCode.Q) && Ball.transform.position.y > transform.position.y && Ball.transform.position.y < transform.position.y + 1) { rb.isKinematic = true; if (Input.GetKeyDown(KeyCode.W) && !Input.GetKeyDown(KeyCode.D)) { ballrb.AddForce(transform.up * 30); StartCoroutine(Wait()); rb.isKinematic = false; } else if (Input.GetKeyDown(KeyCode.D)) { ballrb.AddForce(transform.right * 30); StartCoroutine(Wait()); rb.isKinematic = false; } else if (Input.GetKeyDown(KeyCode.W) && Input.GetKeyDown(KeyCode.D)) { ballrb.AddForce(transform.right * 20); ballrb.AddForce(transform.up * 20); StartCoroutine(Wait()); rb.isKinematic = false; } } } Right now its the raw version without any timing tries, I didnt manage so I kept it like this. Could someone tell me how to modify it in order to make the player be able to have a little time window (say 1 second) to press the next button? Thanks!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server