Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
player controller jitters unity

when I jump up to an object that is a cube I reach the step offset and it jitters for a little bit before falling to the ground again. I can remove the step offset altogether but that's not what I want as my game is baste around parkour. when I was making this I was following a Brackeys tutorial on YouTube. Brackeys tutorial. can anyone help me out? ,first person object , the object causing most problems, objects in scene

using System.collections;
using System.Collections.Generic;
using UnityEngine;

public class keymovement : MonoBehaviour
{
public CharacterController controller;


public float speed = 12f;
public float gravity = -10f;

public Transform groundcheck;
public float groundDistance = 0.5f;
public LayerMask groundMask;

public float jumpheight = 3f;

Vector3 velocity; 
bool isgrounded;


void Update()
{
    isgrounded = Physics.CheckSphere(groundcheck.position, groundDistance, groundMask);

   

    if (isgrounded && velocity.y < 0)

    {
        velocity.y = -2;
  }

    float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");

    Vector3 move = transform.right * x + transform.forward * z;
    
    controller.Move(move * speed * Time.deltaTime);

    if (Input.GetButton("jump") && isgrounded)
    {
        velocity.y = Mathf.Sqrt(jumpheight * -2f * gravity);
    }

    velocity.y += gravity * Time.deltaTime;

    controller.Move(velocity * Time.deltaTime);
    }

      
    }
    }
    }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Basically, the Character controller is fighting with the velocity of the movement script because of how it checks for slopes and steps.

An easy fix is to set the controller's slopeLimit to 90f while you are jumping:

void Update()
{
    isgrounded = Physics.CheckSphere(groundcheck.position, groundDistance, groundMask);

    if (isgrounded && velocity.y < 0)

    {
        velocity.y = -2;
        controller.slopeLimit = 45f;
    }
    
    float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");

    Vector3 move = transform.right * x + transform.forward * z;

    controller.Move(move * speed * Time.deltaTime);

    if (Input.GetButton("Jump") && isgrounded)
    {
        velocity.y = Mathf.Sqrt(jumpheight * -2f * gravity);
        controller.slopeLimit = 90f;
    }

    velocity.y += gravity * Time.deltaTime;

    controller.Move(velocity * Time.deltaTime);
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!