Hello everyone, have have some small issue, but i still can’t understand, what;s wrong. I have jump system: Character (with capsule collider and rigid body, and they set up properly), Empty gameobject with ray, for detecting is Player grounded
Before i added jump animations - everything worked correctly. I have 3 jump animations
- Anticipation
- Floating
- Landing
When Floating is playing - my character falling really slow, without animation I have normal fall speed
Here is my code
public class Jump : DragControllerForwad
{
public float jumpHeight = 10f;
public bool isGrounded;
//Character rigid body
public Rigidbody rb;
//Character animator
[SerializeField]
Animator anim;
void Start()
{
rb = transform.Find("animation").GetComponent<Rigidbody>();
anim = transform.Find("animation").GetComponent<Animator>();
}
void Update()
{
RayCasting();
}
// Ray for detecting ground
protected override void RayCasting()
{
Ray ray = new Ray(transform.position, transform.forward);
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo, .5f))
{
Debug.DrawLine(ray.origin, ray.origin + ray.direction * .5f, Color.green);
if (hitInfo.collider.tag == "Ground")
{
isGrounded = true;
}
else
{
isGrounded = false;
}
}
else
{
isGrounded = false;
Debug.DrawLine(ray.origin, ray.origin + ray.direction * .5f, Color.red);
}
// Code for jump animations
if (isGrounded == true)
{
anim.SetBool("isJump", false);
if (Input.GetKeyDown(KeyCode.Space))
{
rb.AddForce(Vector3.up * jumpHeight, ForceMode.Impulse);
}
}
else if(isGrounded == false)
{
anim.SetBool("isJump", true);
}
}
}
My animator controller: