Character Movement Overview
Players will be in control of a single Character while within the LocalMap scenes. Their movement will take place on a 2D plane in an isometric view, with the ability to move north, south, east or west (up, down, left and right respectively).
Movement will be based on a grid system. The character objects will move from one grid space to an empty adjacent grid space when the relevant input is received.
Control of this character will primarily be with the keyboard, with the mouse being reserved for interacting with UI and menu elements.
Characters have two move speeds: walk and sprint
Players move at a rate of approximately 2 grid cells per second (equivalent to meters) at standard walking speed
At sprinting speed, the player moves twice as fast (4 grid cells per second)
Movement will be handled with a CharacterMovement script. Inputs as follows:
Move Up: W key
Move down: S key
Move left: A key
Move right: D key
Sprint (double movement speed): Left Shift
CharacterMovement PseudoCode
//script will be attached to a Character object
//float variable for the character movement speed
//float variable for the character sprint modifier
//Vector2 for storing the Character's current direction (X for up/down, Y for left/right)
//on each frame of the update function
//check if either W,A,S or D have been pushed
//if the character is already facing in the direction of the button press (eg, facing Up when W is pressed) then check if the adjacent grid space in that direction is empty
//if the space is empty then interpolate the Characters position from their current grid space to the adjacent one
//if the sprint key isn't being held the time for interpolating between the old position to the new position is the movement speed
//if the sprint key is being held then modify that movement speed by the sprint modifier
//other wise do not move
//if the Character isn't already facing that direction then turn them to face that direction
Interaction Overview
The majority of player-driven events within the game will be driven by the Interaction system, centered on an Interaction component attached to each Character.
This will work by calling an interface on an interactable node with the "Interact" method. Each interactable node (an object with both a script that implements the interface, and a trigger collider), will consist of *Stations and *Resources (e.g. CookStation or MetalNode )
The method will take several parameters:
What Tool the Character has equipped
What Class the Character is
Whenever a player is within range of an interactable object such as a *Station/*Node and hits the Interact key, the Interact method will be called on the interactable object. It will be passed the Tool and Class of the Character initiating the interaction and check if the Tool matches what it needs before executing its functionality. The exact functionality may also be modified based on the Class.
The Interaction script will also contain methods which will be triggered by different types of interactions. These can add Resources to a Character inventory, remove the Resources and add them to another inventory, heal damage to a Character or perform some other kind of action through an event.
For example a *Node might be a FishNode which will provide RawFood as a resource when interacted with. If a Character interacts with the FishNode without a Fish_Collect_Tool then nothing will happen. If they interact with the FishNode with the Tool then the FishNode will trigger the AddRawFood method on the Character's Interaction script, adding a set amount of RawFood to the Character's inventory. If the Character class is that of Hunter, the amount of RawFood added with a successful interaction would be higher.
The below flowcharts show both the generic outline for how the Interaction system would work and a specific example (a FoodNode)