Week 1 Player Movement


Week 1 DevLog - Player Movement

Basic Movement

The first project update saw the implementation of basic movement to the player character. The player object can be controlled on a horizontal axis using the 'WASD' keys or the arrow keys. The speed at which the object moves can be modified by changing a 'speed' variable. The option to change the speed while the game is running will be used when power-ups are added in the future. While the 'Shift' key is held, the object’s speed is multiplied, causing a 'sprint' effect. This multiplier is also a modifiable variable allowing the option for modification by power-ups. The 'Space' key, when pressed, causes the player object to jump vertically while still being moved horizontally in the air. The amount of horizontal movement allowed while in the air will be subject to change in the future to make the game more or less challenging. To that end, separate 'Jump' and 'OnGround' methods are included in the movement script. The methods can also return a value which allows the animation controller to understand what state the object is currently in and animate accordingly


Player Animation

Using temporary sprites, the player object now has an east and west 'walking' animation that plays when the relevant keys are held. It also has an idle animation which is currently just a front-on view 'walking' animation but was included to allow for easy updating when more appropriate sprites are found/made. Jumping animations are included, one easterly, one westerly, that plays when relevant movement keys are held and the player is in the air, and one vertically which is played when the player is in the air but no movement keys are held. These, like the idle animation, use temporary sprites but are included for ease of further development. The 'OnGround' method makes use of a box cast to determine if the player object is currently in the air or on the ground. It is used by the various animation states to determine when to transition to another state. This allows for accurate determination of the player’s state by checking if there is a physical connection between the player object and the world’s objects.

Pushing Objects

Some testing on whether the player could push other objects was done. This is something that I foresee being a mechanic within the game, but I am yet to work out how I want it to be used. No modifications to the player movement were required; however, it worked to a satisfactory degree by default.

Wall Jumping

By far the most difficult addition in this update was implementing a wall-jumping mechanic. Using the ray casts, we can determine if the player object is on a wall or not. If it is, the object's gravity is turned off, making the player attached to the wall. If the jump button and nothing else is pressed, the object will be sent in the opposite direction. If the jump button and a movement key are pressed, the object will be sent backward slightly and up slightly. The intention was to appear to be jumping in a vertical arc, but the implementation doesn’t look quite right. Some values are going to need to be played around with to make this look more natural, but in its current form it is functional.


Files

DevLog Week 1 Player Movement (Full Version) 2.9 MB
May 05, 2024

Get Skybound Ascension