Im having a problem in which the ball jumps in the first platform at a certain amount of jump height but when it gets to the 2nd one the jump height reduces to about 1/4 from the first step, how do i keep a constant jump height on every platform.
The ball is actually just obeying the laws of physics and in order to make the ball jump higher with each bounce you need to add energy to the ball, probably by change the velocity of the ball when it collides with a platform. Here is a script to get you started
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
void FixedUpdate() {
if (Input.GetButton(KeyCode.Mouse0)){
rigidbody.velocity = new Vector3(rigidbody.velocity.x, 10, rigidbody.velocity.z);
}
}
// try changing the rigidbody velocity here
void OnCollisionEnter(Collision collision) {
}
void OnCollisionStay(Collision collision) {
}
}
Edit:
Sorry, if you are doing 2D then you need to be using OnCollisionEnter2D(Collision2D collision), ie
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
void OnCollisionEnter2D(Collision2D coll) {
rigidbody2D.velocity=new Vector2(rigidbody2D.velocity.x, 10);
}
}