#Issue when using MoveDirectional and Move function

4 messages · Page 1 of 1 (latest)

native pewter
#

I am implementing a Ridgidbody/physics based player movement script

I get the players input and use fixed update to call Move function, then when I dash and apply input my player dashes fine but slows down to the speed I input to the Move function, can someone have a look at my code and review the Move and MoveDirectional functions.
Im also having an issue where if im moving around and looking it seems alittle jittering

Also do a overall review on the code please any feedback would be appreciated

ionic garden
#

Personally I would recommend you splitting your code as you are dealing with very complex behaviours. Like a separate file for Dashing, separate for Jumping etc. Then link them up together within your controller or whatever and call all functions needed. It will make your code much more readable and understandable. And this will help you not have 100 LOC for variables definitions. That's way too many.

If you have conditionals that lead to the end of the function when they are false it is more readable to make it return from the function immediately and not make too much nesting. It is sometimes better to not do that though, it's just for you to know if you don't.

There is no clear entrance point. You have a whole scripts named PlayerMovement. Then you have a bunch of very specific functions like Look and Jump, and you have one named Movement that is clearly meant to be the entry point for all your movement-related stuff. It is called inside FixedUpdate, but in the very same function not-put-in-function logic is also present, which makes it all less readable.

You did good job utilizing events. But for the UI at 126 LOC you should have done just that. Updating UI from fixed update inside your player movement class is a bad idea.

As I can see from these fragments of code, Timer could be not a MonoBehaviour, therefore helping you free some space in inspector and omitting unnecessary stuff there. You might need it though I don't know.

I really like your use of attributes. You could use NaughtyAttributes to make it all even better.

I suppose you have other scripts on the player too, so for that I would make a separate script to manage their execution order and initialization, so that there are no conflicts and you can easily control everything from one script. One Update, one FixedUpdate etc for all. Then it is much easier to read. And yeah as meantioned before, split your code into separate files.

#

I couldn't find the issue because the code is unreadable due to the reasons mentioned in the previous message