Translate Problem

hii all…

I have one lion jump animation which is in loop.

I want to translate forward with jump animation that i can do via transform.Translate.

But i have one some complex situation : i am making lion jump to cross river . Lion will continuously jump and move forward if it collides to wood plank.

and if lion does not colide at the end of jump to the wooden plank then it should fall down.

My problem is how do i find that lion has not collided at the end of jump time.

Or is there any other way to find out this ?

bool isGrounded = true;
 
 // ...
 
 void OnCollisionStay(Collision other)
 {
     if(other.CompareTag("platform"))
     {
         isGrounded = true;
     }
 }
 
 void OnCollisionExit(Collision other)
 {
     if(other.CompareTag("platform"))
     {
         isGrounded = false;
     }
 }

This is the code by which i can find object is colliding or not but how do i check this on jump animation end. and how do i make lion to move forward or fall down.

I would do something along those lines:

  void OnCollisionExit(Collision other)
  {
      if(other.CompareTag("platform") && !animation.IsPlaying("Lionjump"))
      {
          isGrounded = false;
          animation.Play("Lionfall");
      }
  }

This should work as the code I added reads if the animtion called (“i dont know”) is NOT playing than do this.
Now you might need to modify the name of the animation and you would have to reference the animation at the start of your script but either than that from what you have said this method should work. I havent tested it so, just leave a comment if you have any issues

The lion will already fall right? Then why would you need to check if it falls or not, it just falls if there is no contact. If your problem is about colliding, i would suggest using raycasts. Just raycast below lion for ground (or logs, water, whatever) and get distance, if distance is below some value determined by you, simply set state to grounded. Then do the job in Update() method.