Make a player jump when he jumps on a spring!!

Hi there!

I have a prop gameobject “Spring” with a box collider set to triger.

So, whenever player jumps over the spring, he gets lifted in the direction the spring is facing.

You can have the images for the mechanics of the props.

The above image shows the first mechanic. Player jumps over the spring, and he gets thrown upward.

Note: This upward direction is what I want. That is, the spring can be rotated in like left, right, up, and down direction.

I want the spring to throw the player in the direction it is facing the arrow. And, yeah, it includes diagonal push or throw. The picture below shows just that!

Now, I am not saying I can’t do this simple problem.

I do have a solution to the problem i.e. The player already has character controller attached to it. Now, When player jumps on the trigger, the spring will add jumpSpeed to the playerController Script that controls the Charactercontroller.

Easily said, right?? That solution is for upward direction. But I also want downward, left, right, diagonal, etc. And, that through the character controller is hell!!

Complexity will rise when I tell that the Enemy AI can also use this spring. Now complexity goes sky high.


I was thinking the solution to be a better one. All I want is that the Spring applies a force or velocity on the Enemy or the player in the direction I specify it through vector3 mostly.

So, force should be able to do that, right??

Thing is, I do not know that!!!

So, any suggestions guyz!

Note: Game is being developed under Unity 3.5.7f6 Windows for Android.

Thank you for your support!!

You have many choices. I’ll explain the two more obvious.

1) Use the UP vector of the spring
When the player enters the trigger and press the jump key, just get the LOCAL up vector for the spring like this:

Vector3 springUp = SpringObject.transform.up

That way you can rotate the spring and still get the correct Up vector of the spring, then apply a force to the player equals to that up vector multiplied by the magnitude of the force.

2) Expose a Vector3 property in the inspector of the Spring
You could also use a public Vector3 field and set it in the inspector. You then apply that vector as force when the player is in the trigger. This way you can tweak the direction and intensity of the force for each individual spring (some may be more bouncy than other?)

Hope that’s what you wanted. If not, just be more specific and I’ll try to answer :slight_smile:

Oh, to apply a force you need a rigidbody attached to the entity and then through script use rigidbody.AddForce or rigidbody.AddExplosionForce.