#9 | 2023-06-26 | Fixing Collision Bug #1


Hello!

From the testing and the feedback I received, I observed a collision bug.

When the player collides with an angled tile, they get stuck and can only be unstuck my pressing the jump key. The player is supposed to move up the angled tile but this prevents it.

Searching for a solution took time, but nothing I found fit the bug nor worked to fix it. I had to come up with my own solution. Initially, I thought creating a prefab in the shape of the tile with a modified collider would work. The first iteration didn't work, but the second did.

Because there isn't a built in triangle collider, I made my own using the polygon collider. Quick and simple, but it gets the job done.

Using this prefab, I observed that the player could move halfway up the object but would fall down. I figured that if I increased the player's speed when they collide with this object they would be able to make it up. I created a script to facilitate this.

When the player is colliding with this object, I multiplied the "moveSpeed" value of all player controllers buy a set value, being changed as needed.

Since the player's speed was increased when colliding with this object, I had to reset the speed when the player stopped colliding with it. When the player stops colliding with this object, the "moveSpeed" value of all player controllers is divided by a set value, also changed as needed.

This fix was simple, but a little janky. I'll have to come back to this and make it smoother, but for now it will work.

Next up, improving the game's graphics to better fit the theme of a death factory.


Thanks for reading and stay tuned for the next log!

Get Factory of the Damned

Leave a comment

Log in with itch.io to leave a comment.