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);
}
}