Question by
loaikk9 · Apr 04, 2021 at 04:49 PM ·
c#double-tap
need help with making multiple double tap keys
how can I make the double-tap also work with the other keys "S" & "D" the double-tap only works for one key "A" I tried adding the same code for the rest but it didn't work out do I need to make multiple IEnumerators for each?
IEnumerator ResetTapTimer()
{
yield return new WaitForSeconds(resetTapTimer);
tapTimes = 0;
}
IEnumerator ResetDashDirection()
{
yield return new WaitForSeconds(0.35f);
doubleTap = false;
}
private void DashDirections() //In the Update function
{
if (Input.GetKeyDown(KeyCode.A) && (dashIsAvtive == false))
{
StartCoroutine("ResetTapTimer");
tapTimes++;
}
if (tapTimes >= 2)
{
doubleTap = true;
tapTimes = 0;
}
if(doubleTap == true)
{
rb.AddRelativeForce(Vector3.left * 650);
//Dash Effect
dashIsAvtive = true;
psmesh.IsActive = true;
lights.SetActive(true);
//disable Hit Animation
animator.SetBool("GotHit", false);
animator.SetBool("Run", false);
//Render
gameObject.GetComponentInChildren<SkinnedMeshRenderer>().enabled = false;
//Ignore Collisions
Physics.IgnoreLayerCollision(7, 11, true);
Physics.IgnoreLayerCollision(8, 11, true);
Physics.IgnoreLayerCollision(9, 11, true);
Physics.IgnoreLayerCollision(10, 11, true);
animator.SetBool("Jump", false);
//Post Process
ppVolume.profile.TryGetSettings(out chromaticAb);
chromaticAb.intensity.value = 1f;
ppVolume.profile.TryGetSettings(out aExposure);
aExposure.minLuminance.value = -1.0f;
StartCoroutine(ResetDashDirection());
}
if (Input.GetKey(KeyCode.D) && (dashIsAvtive == false))
{
rb.AddRelativeForce(Vector3.right * 650);
//Dash Effect
dashIsAvtive = true;
psmesh.IsActive = true;
lights.SetActive(true);
//disable Hit Animation
animator.SetBool("GotHit", false);
animator.SetBool("Run", false);
//Render
gameObject.GetComponentInChildren<SkinnedMeshRenderer>().enabled = false;
//Ignore Collisions
Physics.IgnoreLayerCollision(7, 11, true);
Physics.IgnoreLayerCollision(8, 11, true);
Physics.IgnoreLayerCollision(9, 11, true);
Physics.IgnoreLayerCollision(10, 11, true);
animator.SetBool("Jump", false);
//Post Process
ppVolume.profile.TryGetSettings(out chromaticAb);
chromaticAb.intensity.value = 1f;
ppVolume.profile.TryGetSettings(out aExposure);
aExposure.minLuminance.value = -1.0f;
}
if (Input.GetKey(KeyCode.S) && (dashIsAvtive == false))
{
rb.AddRelativeForce(Vector3.back * 650);
//Dash Effect
dashIsAvtive = true;
psmesh.IsActive = true;
lights.SetActive(true);
//disable Hit Animation
animator.SetBool("GotHit", false);
animator.SetBool("Run", false);
//Render
gameObject.GetComponentInChildren<SkinnedMeshRenderer>().enabled = false;
//Ignore Collisions
Physics.IgnoreLayerCollision(7, 11, true);
Physics.IgnoreLayerCollision(8, 11, true);
Physics.IgnoreLayerCollision(9, 11, true);
Physics.IgnoreLayerCollision(10, 11, true);
animator.SetBool("Jump", false);
animator.SetBool("Run", false);
//Post Process
ppVolume.profile.TryGetSettings(out chromaticAb);
chromaticAb.intensity.value = 1f;
ppVolume.profile.TryGetSettings(out aExposure);
aExposure.minLuminance.value = -1.0f;
}
}
Comment
Your answer
Follow this Question
Related Questions
Double tap to reduce score by 2 points 0 Answers
How to make custom input key presses 0 Answers
Free Look Camera Rig Changing Rotation 1 Answer
Save a list for refrence? 0 Answers
Need help with coding 0 Answers