Game
Project: Blue
9 years ago

New Hazard Mechanic


The arsenal of traps at our disposal has not really changed in some months. We have the swinging log trap, a bear trap, a patch of fire, and the trapdoor / disappearing ground.

Some of these are pretty standard, and I wanted to add something new for the player to dodge, something that needs quick reflexes, so I thought of building a trap where a Log will fly at the player from off screen.

Setting up the foundation for the trap is actually pretty easy and just copied over from our swinging log trap. I take the log sprite that is used in the other unity prefab and I position it off camera and I give it a RigidBody2D.

5d0b6a2eb42f1.png

Inside of the Unity Editor I selected to freeze the X, Y and Z rotation so that the log will stay suspended in mid air and not fall to the ground. Inside of our levels we have a custom script to trigger all of our hazards when the player has reached a specific distance from each hazard, so to be able to test it with the amount of velocity and force I had given it, I quickly coded a script to trigger the trap when I pressed the space bar, something along the lines of

void update ()
{
if (Input.GetKeyDown (KeyCode.Space))
release ();
}

When I pressed the spacebar the Log flew into action

5d0b6a2f50777.gif

That was pretty weak, so I needed to increase the velocity and force, which is just a matter of going back into the source code and changing a couple of the variables to get them to where I want. But the log didn’t have any spin to make it look like it was thrown. Looking through the Unity Documentation I found the perfect thing to add, torque through the Rigidbody2D. I fiddled with the numbers a little bit more and got a result more to my taste.

5d0b6a31b925b.gif

I changed the script a little bit more to make the velocity, force and torque slightly random each time the trap is triggered and threw it into the game and this I am very pleased with the results. After only about 2 hours of work we have a brand new trap, that requires really quick reflexes, in our game.

5d0b6a34802a9.gif


0 comments

Loading...

Next up

Short intro of us πŸ’•βœŒοΈ

We're an eletro duo based in Seoul πŸ‡°πŸ‡· Heavily influenced by the 90s.

Our new album #Xennials is all about the nostalgia of that era πŸ’½ CD listenin πŸ“Ÿ beeper beepin πŸ’Ύ floppy disks floppin days 😎

Stream now! 🎧

https://open.spotify.com/album/3YwWhnHWVy5cA8XOpbaGRA?si=8E9awqU…

So

i may or may not make an full art of some person or i may just leave this like that-

We are under attack!

"Thanks guys for endless hours of fun." πŸ‘

(My first fan art. Read the article, please.)

#sonic #mario #photoshop

I have added rewards for quests so that villagers can give you something in return for your hard work helping them. πŸ₯³

I want to know - what's your favourite quest reward?

Call it 'wrong turn'!🚫 The feeling of running into a house with only one exitπŸšͺ, and being doomed to die. #pixelart #pixelartist #pixelartwork #art #pixel #indiegame #IndieGameDev #indieartist

Regional Bulbasaur. #Pokemon

it happens

Explosive domino effect