Rigidbody2d addforce is weaker at a higher y position.

When my player object jumps on a higher terrain, it doesn’t jump nearly as high. Here’s my jump code.

#pragma strict

var BounceObj : GameObject;
var jumpHeight : float;

function Start () {

}

function Update () {

	
}

function OnCollisionStay2D (col : Collision2D ) {
	
	if( col.gameObject.name== BounceObj.name && Input.GetKey(KeyCode.W)) {
		
		
		rigidbody2D.AddForce (Vector2 ( 0, jumpHeight * 10 ));
	}
	

}

So when the cube player goes on the higher ground and I jump, it doesnt jump as high as if it were on the lower floor.

Since you use GetKey and OnCollisionStay this might be a problem how long your player touches your collider.

I’m pretty sure that you do multiple AddForce per jump as while holding down your jump key and while you’re touching the collider you do an addforce each frame.

If you want a more predictable result, use GetKeyDown instead of GetKey.

Alright I figured it out. I guess it didn’t like how I set up the collision if condition

Instead of using a variable to store the floor gameobject, I tried making a tag that every floor object will share, and making the condition use that instead. Here’s an example of the code I used.

function OnCollisionStay2D (col : Collision2D ) {

if( col.gameObject.tag== "Floor" && Input.GetKey(KeyCode.W)) {
	
	
	rigidbody2D.AddForce ( Vector2 ( 0, jumpHeight * 100));

	
}

}

Hopefully this will help anyone with a similar issue.