Question by
Aitorqq · Nov 17, 2016 at 10:20 PM ·
inputcollision detectionnot workinggetkeydown
Input not working after colision
I all, I'm having a problem with Input and colliders.
When my character has not been triggered by onCollisionEnter2d this function works perfect:
void FixedUpdate () {
applyPlanetPhysics();
giveCorrectAngleToAstronaut();
}
void Update()
{
applyControls();
Debug.Log("in update");
}
void applyControls()
{
Debug.Log("Applycontrols");
if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("key pressed");
Debug.Log("key pressed collided= " + collided);
if (collided)
{
Debug.Log("key pressed and collided");
jumped = true;
Vector2 vectorForce = planet.transform.position - gameObject.transform.position;
gameObject.GetComponent<Rigidbody2D>().AddForce(-vectorForce * jumpK);
}
}
}
But if the character detects a collision Input never works again.
I'm able to see in logs:
console: applyControls
but nothing more.
Comment
you'd have to at least see "key pressed" when pressing the space bar despite gotten triggered or not,because everything else is impossible codewise.
or you managed to programmatically plug the keyboard out :)
Your answer
![](https://koobas.hobune.stream/wayback/20220612100903im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
GetKeyUp does not get called sometimes. 1 Answer
Keyboard input not working in testing 0 Answers
Lerping from one position to another not working 2 Answers
GetKeyDown not always registering 1 Answer