jeudi 1 juillet 2021

Unity design pattern with character movement

I created character movement (Player movement, root animation, player rotation, camera rotation) in one script. Of course that is not a good thing and of course i want to split up the code. But now I want to know how to make it better.

My thoughts was to seperate all logic:

  • CharacterMovement.cs (Player movement, rotation)
  • CharacterLocomotion.cs (Animation)
  • CharacterCameraRotation.cs (Camera)
  • InputReader.cs (new Input System reader)

and create CharacterPlayerController.cs, get references to all scripts and manipulate them in single Update().

So will it be better if I will tried to implement Mediator pattern? Or maybe use Visitor pattern?

In the future i want to implement IK system, Rig system, Climb system.

Maybe I'm thinking wrong and someone could tell me how to make it correct.

Aucun commentaire:

Enregistrer un commentaire