Your Cart
Loading
unity 3d character jump unity3d player jump unity jump mechanic

Unity 3D Character Jump | Unity Tutorial

Unity 3D Character Jump | Unity Tutorial


Unlock the secrets of dynamic character movement in Unity 3D with our step-by-step tutorial on implementing character jumps! Whether you're a beginner or looking to refine your skills, this video will guide you through setting up jump mechanics, adjusting gravity, and adding smooth transitions for a natural jumping experience. Dive in and elevate your game development with responsive and realistic character jumps!



WATCH FULL TUTORIAL ON YOUTUBE



CHECK OUR PROJECTS


SUBSCRIBE FOR LATEST OFFERS



=========================================================


Unity Projects - ON SALE!!!


1. Water Sort Puzzle 9000 Levels

https://payhip.com/b/cjDb8


2. Ball Sort Puzzle 9000 Levels

https://payhip.com/b/IbtoD


3. Sling Shot

https://payhip.com/b/PjLDH



=========================================================



Script:


using UnityEngine;


public class PlayerJump : MonoBehaviour

{

  public float moveSpeed = 5f;  // Speed at which the character moves

  public float jumpForce = 5f;  // Force applied when jumping

  public Transform groundCheck; // Point used to check if the player is on the ground

  public float groundCheckRadius = 0.2f; // Radius of the ground check

  public LayerMask groundLayer; // Layer that represents the ground


  private Rigidbody rb;

  private bool isGrounded;


  void Start()

  {

    rb = GetComponent<Rigidbody>();

  }


  void Update()

  {

    // Check if the player is on the ground

    isGrounded = Physics.CheckSphere(groundCheck.position, groundCheckRadius, groundLayer);


    // Handle movement

    float moveHorizontal = Input.GetAxis("Horizontal");

    float moveVertical = Input.GetAxis("Vertical");

    Vector3 movement = new Vector3(moveHorizontal, 0, moveVertical) * moveSpeed * Time.deltaTime;

    transform.Translate(movement);


    // Handle jumping

    if (isGrounded && Input.GetButtonDown("Jump"))

    {

      rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);

    }

  }

}





DOWNLOAD CODESTER FILES