Nyrava
August 24, 2024, 3:32pm
1
I was trying to use CharacterController but my player kept sliding and teleporting back to fixed location when I pressed any movement key. This was the line of code that I changed
controller.Move(moveDir.normalized * speed * Time.deltaTime);
I changed that to this and now everything works perfectly fine :
transform.position += (moveDir.normalized * speed * Time.deltaTime);
was I doing something wrong? Is the new line I wrote okay to use? Thank you
You probably have some other bug or issues in your setup.
If you just need a simple CC, help yourself… here’s two:
Welcome!
First, please use code tags: Using code tags properly when you post code.
But secondly, what is weird is that this is the second time recently that I’ve seen this code reported broken.
I went and investigated and what appears to have happened is that Unity’s example used to work back on earlier versions of Unity.
BUT… on more recent Unity versions, I concur with you that it presently does NOT work reliably, at least for jumping.
If I had to guess why, I believe it is their two sepa…
If you would prefer something more full-featured here is a super-basic starter prototype FPS based on Character Controller (BasicFPCC):
[BasicFPCC - A basic first person character controller]
Gist Link
After some interest in an old post here , I spent the weekend frankensteining snippets of code to make a single script FPCC that could be used like the FPCC from Unity 4~5, including the crouch and run from Aldo, and I also added farcry sliding. There is a Menu Item function to easily create and configure a new FPCC object. Otherwise very easy to set up, it only requires a layer to exclude itself from sphere/raycasts…
That one has run, walk, jump, slide, crouch… it’s crazy-nutty!!
1 Like