Please help me with FPS Movement...

Hello gameDevs. I seriously need some help with fps movement. I am making a parkour fps game which has physics + transform based movement. Everything goes well, all codes written and tested, and suddenly there starts extremely choppy gameplay. At 200 + fps, things feel like < 30. Also it occurs suddenly, and has ruined 5 attempts of mine to make fps movement already. I tried decreasing fixed timestep and things got fine, then I added grappling mechanic, which introduced choppiness, so I removed it, but even so choppiness still persists. ALSO : My camera is a child of the player, should I try Cam.transform.position = Player.transform.position?
Please help. Let me know if you need scripts. HELP NEEDED. Thanks in advance… Btw, I am using URP

think maybe you have a rigidbody you should be .positioning instead? the rigidbody expects a stable transform or something i think Reddit - Dive into anything

I tried the same code again in a fresh new project, still super choppy…
Here is the main Movement Code

6919721–811676–PlayerMove.cs (3.51 KB)

So apparently, I should make the motion wholely rigidbody? Please let me know

And Also, would Rigidbody.movePosition work with a kinematic rigidbody?

Apparently, such meaningless problems don’t haunt us in unreal. Please help or the only choice would be to restart in unreal…

I think the variables set with transform in your start method are fine, but I would try swapping out the two with .translate and .rotate for a rigidbody reference instead, either through getComponent like you do later or a public rigidbody variable. Only thing that really stands out to me is that with the “w” button your using transform.translate and rigidbody.addrelative force at the same time and I think you might want to rewrite the first one in the format of the second one without the endforce multiplier your saving for the getbuttonup. Dunno if that would create as bad problems as you mentioned though. Parenting the camera to the player shouldnt cause any problems though and the camera should automatically follow and rotate with the player without a script.

I see this line in your code:

 transform.Translate(Vector3.forward * Time.deltaTime * movespeed);

Do not ever move a Rigidbody connected object by manipulating the transform directly.

Doing so bypasses the physics engine and you startle it, making it wig out and possibly produce massively spiky uneven forces to try and solve the problem.

Instead, always use the .MovePosition() method on the Rigidbody, as well as the .MoveRotation()

2 Likes

Okk. Thanks for your reply, I will surely try this. But I have done the same moving rb through transform several times before. Is it surely the reason? btw, I will try your idea as soon as I reach my work device… thanks

Thanks for your reply. Actually I am adding impulsive force on getkeyup. This is to ensure that from a high speed, the player doesn’t stop in a millisecond. I think I did not get you, can you please explain. Thank you…

A request here. If any of you are free, may I ask you to run this on your pc. That may be helpful since my pc doesn’t have a lot of specs. Thanks in advance

Aight guys
Thanks sooo much for your help. Wasn’t able to reply because I had exams and now I am out of em, alive. As for the issue, I now know the cause, EXTREMELY CHOPPY EDITOR, which is probably a bug . But I can test with builds. Also I have rewritten the script and it now is fully physics based which I am absolutely vibing with… Thanks sooo much for your help guys. You are all awesome…