Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

154
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda