Character jump on collision

Hi Unity people, I could really use a bit of help. Im a bit of a noob when it comes to scripting so I apoligise in advance.

I am trying to expand upon the current 2d game tutorial. I am using the 2d character controller.

My goal is quite simple…

After the player has jumped (and is still in the air),
if he comes into contact with a particular collider,
if the jump button is pressed,
Make him jump a bit higher,
and play character animation.

Any scripting examples would be very welcome. Ive done a bunch of tutorials but cant find what im after and I have been at this one goal all day!

Thanks in advance guys!

RedWarriorKTF

1 Answer

1

No need to apologize, we were all newbies at some point. :slight_smile:

I’m not sure what your code looks like but the check for the jump button is probably Input.GetKey() which continuously checks if the designated key is pressed.

What you probably should do is change that to Input.GetKeyDown() which will only return true once, when the designated key is pressed, regardless of how long it is pressed.