- Home /
Question by
robbos729 · Jan 25, 2020 at 11:28 PM ·
charactercontrollerjumpplayer movementmasscapsule
Unity my player does not jump
In my 3d game my character doesnt jump even though using a working script. Does anybody know why this is, is it to do with anything in this screenshot. I have made sure all settings are shown in inspector.
And heres the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Jump : MonoBehaviour
{
public Rigidbody rb;
public float jumpForce = 100f;
public void jump()
{
if (Input.GetKey("space"))
{
rb.AddForce(0, jumpForce, 0, ForceMode.VelocityChange);
}
}
}
capsule.png
(297.7 kB)
Comment
Answer by Fariborzzn · Jan 25, 2020 at 11:37 PM
Your Issue is Here istead of using ForceMode.VelocityChange use this:
rb.AddForce(0, jumpForce, 0, ForceMode.Impulse);
Your answer
Follow this Question
Related Questions
How to jump using a CharacterController and NavMeshAgent 0 Answers
My jumping script has errors 1 Answer
Sonic trampoline style with character controller(old one) 1 Answer
Jump with Character Controller 1 Answer
[C#] Jump on slopes 1 Answer