Hey guys, really new here and new to Unity. I am attempting to make a game where you jump to collect coins, those coins push you “x” height higher, and you continue progressing until you miss a coin and fall back to the ground.
This is a 2D game. I have my cube with my sprite, I have the coins coded well enough for now. The issue is when I miss a coin and fall back down, if I hit another coin the jump up doesnt really take affect (I am assuming because my velocity is too quick coming down, cancelling out the force I am trying to push it back up).
Is there any easy way to cancel out current force and apply a given force even if it is in the oppisite direction?
Here is the current code I am using for the collision, jump, and coin movement:
void OnTriggerEnter(Collider col){
if (col.gameObject.tag == "Coin1") {
GameObject.Find("Coin1").transform.position = new Vector3(Random.Range (-10, 10), curHeight, 0);
rigidbody.AddForce(new Vector3(0, 1000, 0), ForceMode.Force);
curHeight += 15;
}