How would you implement the described scenario?

I am struggling with Code design in my 2D Game and having some troubles with the component based system of Unity.

My Design:

My main problem is Single Point of Truth. I want to implement basic movement (to left and to right) only once in Character which I could achieve by programming there something in Update(). However the way the Character is moved from Player and NPC is different of course. The Player is moved by Player Input and NPC is moved by configured Properties. As a example in Player I would need a Update() too in which I track Input and manipulate with this data the Character movement. This doesn’t work because Unity only calls the Update of one class. Which I fully can understand.

So I am breaking my head how to design this scenario in a good way. I am very thankful for any recommendations or some good documentations/guides which I can read.

PS: I don’t have any code to share. This is just a scenario which I am considering about.

I would manage the movement in a dedicated component (a.k.a class). Either use inheritance or interface implementation (better but not really handy in Unity)

Inheritance

  1. Declare an abstract class called MovementController declaring a single function Move( Character character )
  2. In the Character class, declare a public MovementController MovementController
  3. In the Character’s class, make Update a protected virtual function calling MovementController.Move( this )
  4. Create two other classes : PlayerMovementController : MovementController and NPCMovementController : MovementController implementing the Move function
  5. Attach the PlayerMovementController and NPCMovementController to the appropriate gameObjects
  6. Drag & Drop the components attached step 5 into the public field of the Character class

Interface

  1. Create an interface called IMovementController declaring a single function Move( Character character )
  2. In the Character class, declare a private IMovementController MovementController
  3. In the Character’s class, make Update a protected virtual function calling MovementController.Move( this )
  4. Create two other classes : PlayerMovementController : IMovementController and NPCMovementController : IMovementController implementing the Move function
  5. Attach the PlayerMovementController and NPCMovementController to the appropriate gameObjects
  6. Retrieve the MovementController component in the Awake function using GetComponent<IMovementController>