Hi everyone
Im kinda new to Unity. I´ve been doing some tests and one of them is giving me some issues. When I climb a ramp, instead of the character falling when theres no ramp or going down whn going down a slide, it stays midair, it can walk and turn but everything at the same level as the highest position before
Any idea on how to give him some gravity?
Im using a capsule collider and a rigid body with gravity activated but none of those seem to be working
Thanks
Make sure the rigidbody doesnt have its position y constrained in the inspector.
That could be because of rigidbody.Velocity.When you use that method to give your player some speed,gravity works incorrectly.To fix that,i used this script
void Start()
{
rb = gameObject.GetComponent<Rigidbody>();
}
void Update()
{
SetVelocity();
}
private void SetVelocity()
{
rb.AddForce(0, 0, speed * Time.deltaTime, ForceMode.VelocityChange);
if (rb.velocity.magnitude > speed)
{
rb.AddForce(0, 0, -speed * Time.deltaTime, ForceMode.VelocityChange);
}
}
Hope it will help somebody)