#5 | 2023-06-08 | Traps!


Hello!

Making the traps for this game has been a fun challenge. So far, there are 7 (technically 8) traps. Each one is unique and based off of things you would find in a factory (except for the spike and probably the acid barrel).

(You may have noticed that I love using tables)


Making the spikes was very simple and one of the first tiles I made. To make them have a collider, I added a Tilemap Collider onto the grid layer the are placed on.


I quite enjoyed making the Rotary Saws. To make them spin, I used a Hinge Joint 2D component. It was as simple as changing the motor speed vale to 1500 and checking the "Use Motor" box. One day I might make tutorials on this stuff.


To make the saw move back and forth, I wrote a script that makes it move between to points with variable speed. This will make for interesting trap layout in the levels.


The Machine Press/Hammer was an interesting challenge. I had to make use of a looped coroutine and accessing a Rigidbody2D's gravityScale to make this work.

Looping the coroutine was surprisingly easy. All I had to do was create a "while(true)" statement and write the function's code inside of it. One of the cool things about coroutines is that you can create a delay between lines of code being run with "WaitforSeconds". To set the hammer after it fell, I set it's position to that of the parent object minus the "hammerStartPos" Vector3.

I have yet to figure out how to make the drill, furnace, conveyor belt and the acid barrel. I'll come back to those later as the traps I've made so far should be sufficient for the first few levels.

Thanks for reading and stay tuned for the next blog!

Get Factory of the Damned

Leave a comment

Log in with itch.io to leave a comment.