My character moves by itself without me doing anything, I have already reviewed the movement code several times, I even tried trying other methods with the same function (moving the character) and they all continued with the same problem (The code worked in yes, but my character moves infinitely by itself) I also installed and uninstalled versions of unity client to see if it could be solved by doing that but no
Do you think it could be a problem with the unity client? I am using version 2022 although in version 2021 and 2019 the same thing happened to me, could it be some configuration that I touched by accident? And if so, how do I return it to its original state?
Here is one of the codes I used, I also tried with CharacterController
Link
public class PlayerController : MonoBehaviour
{
private new Rigidbody rigidbody;
public float speed = 10f;
void Start()
{
rigidbody = GetComponent();
}
void Update()
{
float hor = Input.GetAxisRaw(“Horizontal”);
float ver = Input.GetAxisRaw(“Vertical”);
if (hor != 0.0f || ver != 0.0f)
{
Vector3 dir = transform.forward * ver + transform.right * hor;
rigidbody.MovePosition(transform.position + dir * speed * Time.deltaTime);
}
}
}
And this is other script i tried using CharacterController
public class PlayerController : MonoBehaviour {
public float horizontalMove;
public float verticalMove;
public CharacterController player;
public float playerspeed;
void Start() {
player = GetComponent();
}
void Update() {
horizontalMove = Input.GetAxis(“Horizontal”);
verticalMove = Input.GetAxis(“Vertical”);
}
private void FixedUpdate()
{
player.Move(new Vector3(horizontalMove, 0, verticalMove) * playerspeed * Time.deltaTime);
}
}
I used when I saw that they did not solve the problem, I saved and deleted from my project, right now I created a new file to focus on finding solutions to the problem, since with any script to move the character this happens to me with rigidbody or CharacterController I tried using the Debug.Log to find out if what was the problem but it didn’t work either It sits on flat ground, I also turned gravity off but the problem was still working. No external forces are applied to the rigid body as it is a new project I made to focus on this problem. I don’t have any other script currently in my project. This is the CharacterController script that I used and it didn’t work for me, I’ll give you the link where I got it too
CharacterController:
RigidBody:
I would be very grateful if you help me solve this error that I have, I have been searching for a solution or explanation for two days in forums and youtube videosa