- Home /
GroundCheck
So i working on an 2D active ragdol. Imagine people playgroud , but simpler . Well when they fall they play 2 animations . One for a simple fall and free fall. Well I cant get the groundcheck to work so that it will play the coresponding animation. Here is my code using System.Collections; using System.Collections.Generic; using UnityEngine; public class FallRagdoll : MonoBehaviour { public List<GameObject> bodyParts; public Animator animator; public bool isgrouded = true; private void Update() { if (isgrouded == true) { animator.SetBool("FreeFalling", false); animator.SetBool("Fall", false); } else if (isgrouded == false && animator.GetBool("FreeFalling") == false) animator.SetBool("FreeFalling", true); } private void OnCollisionStay2D(Collision2D collision) { if (collision.collider.CompareTag("Enviorment")) isgrouded = true; } private void OnCollisionExit2D(Collision2D collision) { if (collision.collider.CompareTag("Enviorment")) isgrouded = false; } private void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.CompareTag("Enviorment")) isgrouded = true; } }
The collider is a boxcollider and it is a trigger . I also tried raycast it just didnt work because the raycast was shoting to an 0 point i guess of the map, so raycasts solutions are also welcome.