- Home /
How to make a 2D "trampoline"?
I'm trying to make a sort of bouncy mushroom my player can jump on and then bounces in the direction the mushroom faces. I'm not exactly sure how to set this up. Do you guys have any suggestions about the easiest way to do this? Here is a video explanation of what I'm talking about: http://www.youtube.com/watch?v=Y00P1hta4yo&feature=related#t=02m17s
Any help is appreciated, thanks guys.
Answer by Muuskii · Jul 11, 2012 at 02:26 AM
Sounds like you would use the OnCollisionEnter function and then check the relativeVelocity against a threshold (to see if we're landing from a jump) and then bounce the player.
If you're not using rigidbodies you will have to use a different method.
Answer by Maru07 · Jul 11, 2012 at 03:04 AM
Haha yeah I v enountered that problem before :D the easiest way is a Trigger around the Mushroom and put "OnTriggerEnter" add.force z -1000 and On Trigger exit z +1000 the z -1000 will make the player jump up every time he hits the ground. Whenever you want to stop this, you simply do +1000. You might have to adjust the force value to your needs and play an animation so the User gets a feedback that the mushroom is actually bouncing but this simple trick will do the job ;)