# Help with platform jumping game

So i’m making a simple game where you have to land on platforms that propel you in the air. and i’m having trouble getting the platforms to add force correctly. When you touch the first one it does it correctly but landing on the second platform adds less force or no force at all.

`````` void OnTriggerEnter(Collider other)
{
if (other.name == "Player")
{

Rigidbody rb = player.GetComponent<Rigidbody>();

}

}
``````

this is what i’m using to propel the character upwards.
i think the problem might be since i’m falling onto the platform its not working right because if the character just walks on to it that’s when it works.

There are two details to point out here:

1. You’re multiplying your “blockPower” by 100 because the force is being divided by (likely) 50. It may be prudent to double the force provided by blockPower (or multiply by 2 in there, if you insist on it), but then apply the force with an appropriate ForceMode. Additionally, if your character’s mass is ever not 1, you will be launched higher or lower as a result (if that’s actually desired).

// ForceMode of VelocityChange ignores mass
// and applies entire force instantaneously

2. You’re using OnTriggerEnter(). There’s nothing specifically wrong with that, but it suggests to me that you’re not colliding with anything. This means that AddForce() is not actually the ideal solution at this point (but I mentioned it and gave an example as a point of reference).

When the force is applied, it’s simply modifying your velocity relative to your current velocity. If you are moving on flat ground, a launch upward will launch you to the expected height. If you’re moving down at the rate you should be launched upward, you’ll simply negate your current motion (what you’re seeing).

To get the effect you’re looking for, we can apply a direct modification to your velocity instead.

``````Rigidbody rb = player.GetComponent<Rigidbody>();
Vector3 vel = rb.velocity;
rb.velocity = new Vector3(vel.x, blockPower, vel.y);
``````

Unless you specifically intend to be able to inherit existing momentum (which can also be done during the direct modification), it’s generally a safer bet to not directly modify velocity. However, there are times when doing so will provide the solution you’re looking for. It’s mainly just not recommended to constantly update your velocity directly, where this application is made situationally (i.e. when entering trigger regions).

Why not use an area effector?

Also, you might want to use OnTriggerStay rather than Enter.

but it stops the player when you land on it? So the collision is being recognized correctly?