Gravity on Player Problem

i have this problem only on the player (that is a mixamo model), as shown on the video his gravity is weird and he falls very slowly.

please help

thank u.

Sasha

ckd6b9

Cannot debug a video so if you’re manipulating a Rigidbody/Transform here then it’s important to show exactly what you’re doing.

If you’re not doing anything to the Rigidbody/Transform then I’ve no idea what’s going on here.

it has a Rigidbody
https://imgur.com/ZgeO1g9

and a PlayeControler.cs:

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

public class PlayerController : MonoBehaviour
{
private Rigidbody playerRigidBody;
private GameObject focalPoint;
private float horizontalInput;
private float verticalInput;
private float mouseX;
public float speed = 10.0f;
//private bool isOnGround = true;
public float jumpForce = 100;

private Animator playerAnimator;

// Start is called before the first frame update
void Start()
{
playerRigidBody = GetComponent();
focalPoint = GameObject.Find(“FocalPoint”);
playerAnimator = GetComponent();
}

// Update is called once per frame
void Update()
{
// Movimiento horizontal del player
horizontalInput = Input.GetAxis(“Horizontal”);
transform.Translate(Vector3.right * horizontalInput * Time.deltaTime * speed);

// Movimiento hace adelante o atras del player
verticalInput = Input.GetAxis(“Vertical”);
transform.Translate(Vector3.forward * verticalInput * Time.deltaTime * speed);
Debug.Log(playerAnimator.GetFloat(“x”));

if (Input.GetAxisRaw(“Vertical”) == 0 && Input.GetAxisRaw(“Horizontal”) == 0)
{
playerAnimator.SetFloat(“x”, 0.0f);
playerAnimator.SetFloat(“y”, 0.0f);
playerAnimator.SetBool(“isRunning_b”, false);
}
else if(Input.GetAxisRaw(“Vertical”) > 0)
{
playerAnimator.SetFloat(“x”, 0.0f);
playerAnimator.SetFloat(“y”, 0.5f);
playerAnimator.SetBool(“isRunning_b”, true);
}
else if(Input.GetAxisRaw(“Vertical”) < 0)
{
playerAnimator.SetFloat(“x”, 0.0f);
playerAnimator.SetFloat(“y”, -0.5f);
playerAnimator.SetBool(“isRunning_b”, false);
}
else if (Input.GetAxisRaw(“Horizontal”) > 0)
{
playerAnimator.SetFloat(“x”, 0.5f);
playerAnimator.SetFloat(“y”, 0.0f);
playerAnimator.SetBool(“isRunning_b”, false);
}
else if (Input.GetAxisRaw(“Horizontal”) < 0)
{
playerAnimator.SetFloat(“x”, -0.5f);
playerAnimator.SetFloat(“y”, 0.0f);
playerAnimator.SetBool(“isRunning_b”, false);
}

// Rotar player en su eje
mouseX = Input.GetAxis(“Mouse X”);
transform.Rotate(0, mouseX, 0);

if (Input.GetKeyDown(KeyCode.Space))
{
playerAnimator.SetTrigger(“jumping_t”);
//playerRigidBody.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
//isOnGround = false;
}
}
}

You can see here you’re bypassing physics and writing to the Transform yourself. That’s the whole point of a Rigidbody; to simulate and write its results to the Transform.

You’re also doing this per-frame which suggests you’ve not followed the starter physics tutorials as those will cover the fact that physics doesn’t run per-frame but each fixed-update.

BTW: Here’s how to post code: https://discussions.unity.com/t/481379

1 Like