How do I make OnTriggerEnter and transform.Translate work together


I am new to programming and I am trying to make a script. This script will make it so that when the player enters the trigger, they are propelled upwards to a certain height then they fall back down, think of it like the player is able to bounce up and down on a spring. How is this done?

  1. Make a collider with “trigger” flag on with no mesh rending.
  2. Add a rigidbody to your player
  3. Add a script to collider. so that In OnTriggerEnter(), add a upward force to player.

So when player step into collider, it will propelled upwards. After it exist the collider trigger area, it will fall down cos no force apply to it. And when it fall in collider again, the force will apply again.


I tried to do this and it would not work. I think I have a friend that can help me. Thanks!