I’m trying to make my jump when the W key is pressed. I’m going to achieve this with the rigidbody2D.velocity route since the game is 2D. Here’s my code.
//jumping
if(canJump == true){
rigidbody2D.velocity.y =10;
Debug.Log("This shows up");
}
}
function OnCollisionStay2D(coll: Collision2D) {
if(coll.gameObject.tag == "Terrain" && Input.GetKeyDown(KeyCode.W)){
canJump = true;
}
else{
canJump = false;
}
}
Anyways, when I press W, the debug log string shows up, but the rigidbody.velocity = 10 is not seeming to have an effect. What is wrong? Thank you!