Have falling object exit from a collider after collision?

Hello Devs,

I have a falling object but at times it gets stuck upon colliders. Now sometimes there are also adjacent colliders, hence it should find a pathway to exit the collider and proceed it’s journey. Now I made a solution if the case is just one collider and no neighbouring colliders blocking the way.

SOLN for one Collider :

void OnCollisionEnter(Collision hit) 
		if(hit.collider.tag == "ROCK")
			ROCK = true;
			col_pos =	this.transform.InverseTransformPoint(hit.transform.position);
			col_pos = new Vector3((-col_pos.x),0,(-col_pos.z));
               }// rigidbody.AddForce(col_pos * reqForce * Time.deltatime);

What I do is I take the relative position of the collider in respective to this transform and calculate the exact opposite direction. This works like a gel, but I need to find a pathway to exit in order to continue falling, it there is another hindrance on the way.

Thank you,

ScreenShot :

This is an image of the player falling towards the ground.

  1. more correct to use this instead of collider’s pivot if you want realistic movements
  2. use triggers instead of colliders if you totally control moves
  3. you should apply ‘AddForce’ every FixedUpdate(), not just once
  4. using OnColliderStay can give better result cause it will call EVERY frame you are in collision
  5. manually avoid situations when you object will got two opposite forces - this will cause object to stuck

Maybe you can give it a little push by adding a velocity in the same direction ?