Coding A Player Controller


☆⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂ ⠂⠄⠄⠂☆

During the early stages of Everdream's development, the team decided we wanted a player controller that was comfortable to use with snappy inputs that also made the player feel like the character was in a dream-like state. This meant finding a way to create a controller that felt slow and floaty like a dream but also still had snappiness and quick action to the inputs from the player.

Finding a balance between these two would be tricky, so I opted to make this controller using a scriptable stats object that would allow for easy customisation of the player movement and could hold multiple types of stats for the team to mess around with. The first decision to make was how the player moved in the script; I opted to use velocity by frame movement as this would allow a more customisable movement style based on how the surrounding environment was affecting the player.

After deciding on the movement, I added stats like Coyote jumps, edge float detects, and queued jumps to the scriptable stats to add that bit of extra versatility to the jump system on the player controller. The player jump was also tied to velocity by frame movement on the Y axis to keep the movement system the same as the horizontal movement.

Once all the basics of the player controller were set up, it was time to add interaction scripts so that our players could interact with the world around them. For the interaction system, I started by putting together a list of the different types of interactions the player could have. Pick up items, grabbing and dropping objects, and examining objects were the first basic ones I started with.

In the interaction script, I created a DetectObject method that would detect anything marked with the interactable tag when it came within a range of the player's detection radius. A Separate item script that was attached to the object would then list the interactable object and the type of interaction it could have. Once the object type was decided, a separate script would be used to call the methods for each interaction type.

Using this separated script method made it easier to create new types of interactions whenever we needed them and integrate them easily into the detection script without messing around with the other types of interactions.



- Ben

☆⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂⠁⠁⠂⠄⠄⠂ ⠂⠄⠄⠂☆

Get The Everdream

Leave a comment

Log in with itch.io to leave a comment.