top of page

My Main Goal

After a brief leave during 2023 to experiment with the Unreal Engine, I returned to Unity in 2024 to make a game as an honors contract in 2024. This time, my goals for the project were much more ambitious than Quest for Treasure. During the development of the previous game, I continued running into scenarios where I wanted to include terrain that could have different inclinations. This would allow me to include more varied terrain, such as hills, for example. I tried multiple times during development to implement a system to accommodate that, but it never worked correctly. Going into the contract, this became my main objective for this project and the feature I spent the majority of the first half of the semester to achieve.

The concept is simple: to detect how the player should move at any one time, I use ray casting. A ray cast is essentially a point that starts at a position in space that points in a certain direction. Depending on the distance specified, it will either move until it reaches a certain distance from the origin or it hits an object that matches a certain criterion. This is useful in this situation because I can use the data received to determine the angle of the terrain. With a few calculations, I turn this angle into a direction that the player will follow based on the ray cast. I initially assumed that implementing this mechanic would be easy since it did not take long for me to come up with the system on paper, but it became very difficult to implement in the engine. There are many scenarios where the system can break if not accounted for correctly. For example, if the player is moving too fast on the corner of a slope, they may be too far away from the slope for the system to calculate correctly if the player should be moving with the slope. It is also possible for the system to get confused on terrain that has steep peaks, causing the player to jitter in those situations. Ironing out those issues took a very long time, but the result was worth the commitment. Compared to before, the level design looks a lot less uniform and more varied than what I could achieve previously.

Visual Example (Raycasts are represented as the Orange lines)

Screenshot 2026-03-04 at 2.00.03 PM.png
Screenshot 2026-03-04 at 2.00.20 PM.png

This is a brief snippet of the code that handles this system. Basically, what is happening here is that I pass into a method a list of rays that I then use to check for terrain under the player. In the case that terrain is found, take the normal and use that to calculate the slope angle and the perpendicular. There are more passes that I have to perform for objects to follow the direction of the terrain, but these lines capture the gist of what is going on.

Thanks to this system, I can add new movement mechanics that utilize it. For example, I added a roll mechanic that builds up speed as the player continues to roll down the slope. It functions like how it works in a Sonic game, except that the roll instantaneously gives speed in this game and can be used midair for additional mobility.

What I Learned

This project was very tough for me on several occasions. The jump between this project and my last was huge in size, so I had to spend much more time on the project than before. Thanks to my perseverance, however, I have a much better grasp of what makes a movement system fun in a platformer. In the future, I can use what I build here as a basis to save development time.

  • YouTube
  • Twitter
  • Facebook
bottom of page