Platformer Movement Values
Last updated
Last updated
As of the last tutorial our game has three tile shape collections:
SolidCollision - the bricks that make up most of the level
IceCollision - floating blocks of ice which should be slippery
WaterCollision - an area of the level where the player should be able to swim
This tutorial shows how to create new platformer values for ice and water, and how to change between them depending on collision type.
Before we change which platformer values are used based on collision, we first need to define the platformer values for the different movement types. As mentioned before, we will have the following platformer values:
Ground - already defined by default
Air - already defined by default
Ice - will apply when user collides with the ice TileShapeCollection
Water - will apply when the user collides with the water TileShapeCollection
To add a new movement value:
Click the Player entity
Click the Entity Input Movement tab
Click the Add Control Values button
Set the following values:
Movement Type = Ice
Max Speed = 160
Speed Up/Down = true (click radio button)
Speed Up Time = 1
Slow Down Time = 1
Jump Speed = 270
Hold to Jump Higher = true (click checkbox)
Max Jump Hold Time = .17
Repeat the process above to create a water movement. Click Add Control Values again, and set the following values:
Movement Type = Water
Max Speed = 120
Speed Up/Down = true (click radio button)
Speed Up Time = 1.3
Speed Down Time = 0.5
Jump Speed = 120
Hold to Jump Higher = true (click checkbox)
Max Jump Hold Time = 0.3
Gravity = 210
Max Falling Speed = 90
Now that we have Ice and Water movement defined, we can write code in the Player class to set the movement values according to what the player has collided with. To do this:
Open the project in Visual Studio
Open Player.cs
Add the following code to CustomActivity:
Now our Player will change movement values when moving on ice and solid ground.
This concludes the platformer movement value tutorials where we use multiple TileShapeCollections to change the movement values for the player between regular ground/air movement, ice, and water movement.