The Player Controller and Input System
Grid Ninja » Devlog
I had to follow some key points while creating the Player Controller and Input System and these are as follows.
- The player is only allowed to move in four directions(left, right, up & down)
- The player cannot switch directly to the opposite direction(Example: If a player is moving towards the "Up" direction, then the player can't directly switch to its opposite direction which is "Down". To move toward the "Down" direction the player has to take a U-Turn, Which is "Left/Right -> Down" ).
- The player can only move from one cell to another one by one. The next point will give you a clear understanding of how the Input System works with the InputBuffer mechanism.
- Let's suppose the time taken to move from one cell to another cell is 0.2 sec. The player gave direction change inputs one after another while it can be within any time interval(the interval can be below 0.2 sec or can be higher than 0.2 sec) and each input needs 0.2 sec for execution which is switching from one cell to another, where I had to execute all inputs of the player while considering the time of moving from one cell to another cell. So to achieve this feature I implemented a player InputBuffer logic, where I maintain an array for storing the player inputs and execute them one after another until the array is not empty while following the FIFO concept. So when the array is empty I break the process of input execution, but I have to restart the process whenever new input gets added to the empty array buffer, for that reason in every input it checks if the array is empty, then restart the input execution process once the new input gets added to the array, else if the array is not empty we don't need to restart the process as it is already in continue process.
- InputBuffer Sequence-diagram:
Input Keys: "A, W, S, D " or "LeftArrow, UpArrow, DownArrow, RightArrow ".
Grid Ninja
Player expand territory and eliminate opponent. Player with big territory wins.
Status | In development |
Author | Goutamraj |
Genre | Strategy |
Tags | Indie, Multiplayer, Ninja, Pixel Art, Top-Down, Two Player, Unity |
Languages | English |
More posts
- AWS EC2 Dedicated Server deployment12 days ago
- Detection of a perfect point to start Flood fill: The Working SolutionOct 06, 2024
- Detection of a perfect point to start Flood fill: The Failed SolutionOct 06, 2024
- Fill Player Territory (Using Flood Fill)Oct 01, 2024
- Player State Machine / State Pattern:Sep 30, 2024
- EnvironmentSep 25, 2024
Leave a comment
Log in with itch.io to leave a comment.