So during in the school The Game Assembly our last course is Specialization. Which is a course that we could make anything we wanted, something that we are interested in. I have always found gameplay fun and interesting to make so I wanted to do a FPS Controller.
My inspiration is from Mirror's Edge and I wanted to create some parkour movements, specific wall running, jumping and some climbing.
Since we only had 5 weeks on us I chose to create this in Unity to get a fast prototype going.
This video is a full run on the course I set up in Unity, showing off everything I managed to make in five weeks.
The wall running was quite tricky to get. Since I had Mirror's Edge as game reference I wanted to try make the player heavy. I added a a downwards velocity which increases by time the further you run on the wall.
I also wanted to make a jump from the wall, the tricky part here was that I wanted to constrain the rotation of the players rotation away from the wall, so you can't look into the wall. I also made so that the camera rotates automatic so it goes in the direction the player runs towards to.
The wall running is activated when getting closeby the wall and presses the jump button, The player then collides, rotates and can jump off the wall.
To achieve an automatic rotation I had to raycast and check for the normal direction that I needed to rotate towards. To figure out which way I had to run towards I used the same method. I figure out the point and normal position then I subtract the new point with the player and I got the direction.
And to not let the player rotate in to the wall when wallrunning I use raycasting on the sides to check if the player has a wall on the left or right side.
In the video you can see the raycast and the normal point I use to figure out running direction and rotation.
In the climbing I wanted to be able to climb and jump away from the climbing wall. So to let the climbing script know that you can climb, I use a WallClimbing tag. So whenever I am near the tag, it triggers and you can then start climb it by walking to it and you could also jump towards it.
When going towards it and start climb I do a raycast and check the normal direction, with that I do a reverse direction and made the player look at the direction when approaching and I could then figure out the players climbing direction with the wall.
The climbing mechanics is used when jumping or pressing against the red climbing area, I use the white and red scheme similar to Mirror's Edge.
In the video I raycast when climbing, this way I prevent player from climbing outside the collider.
I created several box colliders on the wall to figure out the climbing areas on the wall. With this I can check when the player is inside the box and outside.
So I also made a rotation constrain in the climbing, if you look behind you at a certain degree you can not move, so you have to turn your way back again to start climbing.
I use the players forward starting rotation when climbing and then I make certain statements to prevent climbing, jumping and player rotations.
I wanted some interactions with objects in the game. In Mirror's Edge you use several objects to jump higher.
So I thought of doing it similar way like the other movements, I made a new tag and make overlap sphere checks to know if I am close by. I had some struggle to know exactly which point on the object I could jump from to achieve that higher velocity.
I also wanted to avoid jumping from the side of the obstacle so it did not do strange behaviours.
You can see interaction with the red object, when you are closeby and press the jump button you gain upwards velocity.
I made checks for where the object is and the player position and also use the object right direction to figure out the jump point. When I got the point to follow the player I use a raycast from the point and downwards to see if the point is hitting the obstacle, if it does not hit the obstacle it will stop searching.
With figuring out the point collision I know when the player is in front of it so I can not jump on the obstacle from the side anymore and I got a point to jump from.
Now I took the point and the players position to get the jump direction.
I use debug drawlines to show the position checking where the player is at and the object itself to figure out a jumping point.
The jump is now working but the last things I wanted to do is making the camera rotate down and up when interacting with it so I get that a more powerful jump.
To fix that I used some lerping in the players camera and I got it working pretty fast, it may need some more polish but got it working good enough.
I wanted a slide ability to go under certain obstacles. So the ability I created is quite simple.
It activates when the player is sprinting and pressing the crouch button at the same time. It then reduces the player height and go in the forward direction with an amount of speed. I then lock the forward force and you can rotate your head left and right during the slide.
The video show the slide ability go under some of the obstacles in the running course I made.
I wanted more living movement when running so I thought of adding the roll that happens in Mirror's Edge when jumping from higher grounds.
How I did that is that I rotated the character controller in the X rotation, since the main camera is attached to the player object it follows along. I also made a lerp on the roll so it slows down when it is almost finished, to try prevent dizziness from the people who plays.
The roll in the video is achieved when getting a certain amount of downwards velocity.
Sprinting is activated when pressing the shift button. While pressing it, you change the speed multiplier by 150%.
Other than that you move faster there was some bugs, to avoid sprinting in the air I do a check if the player is on the ground. I also wanted to maintain momentum when sprinting and jumping and had to fix that edge case so it does not interrupt the speed when jumping.
I also added a small head movement when walking, it goes slightly up and down when walking and then increases while running.
You can see the sprinting in action, it has an instantaneous velocity change when pressed there is no build up, it has sort of like Doom Eternal style sprint.
After this five weeks project I am quite happy with the result. There is definitely more I could add regarding movement. Mirror's Edge is a massive parkour game with a lot of crazy maneuvers you can do, would love to add a hookshot and the ability to swing from bars but there was not enough time in this school project.
Some things I would like to improve is the camera rotations while doing a lot of the parkouring, tilting while wall running, more feedback when you do certain jumps and could polish the current jump camera rotations as well.