Hello everyone, how are you doing?
Soo i’m in a bit of a debate here, with myself, on how to approach this problem. The thing is that I have two types of characters, each one with basic movement (up, down, left and right) but each of them has specific input (one shoots the other doesn’t). What is your opinion on the matter? Is it better to use one script for each type of character thus duplicating code or having a basic movement script and have a script for each type of character?
Thanks in advance guys.
I think you should make a class called PlayerInput. In the PlayerInput you can make a method for moving. for your “hunter” you can derive the class so:
public class HunterPlayerInput : PlayerInput {
void InputClick(){
Shoot();
}
}
So you can add the simple PlayerInput component to your “simple” player and the HunterPlayerInput to your player who can shoot. If you need that more complex you can always derive your PlayerInput or give it virtual methods what you can override. This way you avoid code duplicating and it’s also very clear and nice solution