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.Normalize();
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.
http://postimage.org/image/vmnfmtljt/