Game Project using POLYGON Farm - Low Poly 3D Art

I’m wondering how to stop my player character from slightly rising at the start of the game. It stops rising shortly after I enter play mode. I tried to see if the character’s rigid body mass, axes constraints, or initial velocity caused the problem. I also tried changing the code without success. The brown floor/dirt ground isn’t touching the character and wasn’t altered. Is there something else I should try or a coding solution? Let me know if you need more information, thanks.

using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
    public float moveSpeed = 5.0f; // Adjust the move speed as needed.
    private Rigidbody playerRigidbody;

    void Start()
        playerRigidbody = GetComponent<Rigidbody>();

    void Update()
        // Handle player movement logic here.
        float horizontalInput = Input.GetAxis("Horizontal");
        float verticalInput = Input.GetAxis("Vertical");

        Vector3 movement = new Vector3(horizontalInput, 0, verticalInput) * moveSpeed * Time.deltaTime;

        // Apply the movement to the Rigidbody.
        playerRigidbody.MovePosition(transform.position + movement);

Your character appears to be at y-position 0, but your ground is at -0.11. Perhaps this is the problem but I can’t be sure

When I removed the dirt ground the issue went away. But how could that be since the movable character wasn’t touching the ground?

It’s possible that the ground and the ground’s collider wasn’t lined up anymore. But I cannot be 100% sure

1 Like

Ok. One other question, when I use the key inputs to move my character it moves rather slowly/sluggishly. Is there a simple solution?

You’re moving a rigidbody in Update. It should really be in FixedUpdate because MovePosition (which is also supposed to be used with kinematic rigidbodies) only moves in the physics update.
See here: Unity - Scripting API: Rigidbody.MovePosition

1 Like


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms