Hello, I want to make it so that the player is in the collider with the ladder tag and when the button is pressed, it automatically rises up at a certain speed and so that it moves until it leaves the collider. I used this code but the player moves only when the button is pressed, does anyone know how to make it so that when you press the button once, player rises until it leaves the collider.
private void OnTriggerStay2D(Collider2D other)
{
if (other.gameObject.CompareTag(“Ladder”))
{
if (Input.GetKeyDown(KeyCode.Space))
{
anim.SetTrigger(“Climb”);
transform.Translate(Vector2.up * speed * Time.deltaTime);
}
}