Prototypes: Generating Customs (Part 2)

Now that I have the animations in place for the scene, the ‘machine’ has to be set in place to create the game puzzle. I have the place for the customs set up and the code for them working. So, I just need to create the chain of events that allow the fruit to fall from the tree which completes the level. Below is in an image of the scene I have built in Unity to simulate the level and get my testing under way.

Screen Shot 2018-03-15 at 13.31.50

I placed the fruit in the tree, added a rigid body to it, turned off simulated so it can hang in the tree and created a new script that would allow it to fall. I attached the script to the tree and this is the game object that would be receiving the contact in order to start the chain of events happening. So, when the broken tree is hit by the boulders, it will fall and make contact with the tree, and once that occurs the rigid body of the fruit will activate and fall down to the forest floor, completing the level. The code for this interaction is shown below:

Screen Shot 2018-03-15 at 13.42.04

The next step was creating an event that causes the boulder pile to collapse and push the tree over. I already had the rock grab/throw from the previous scene so just needed to create interactions for the boulders to be broken. I created them in a pile named “Boulder Collection”, gave them all rigid bodies and placed a small stick in front of them on a slope so they wouldn’t move on game start. The stick wedged below them is a small hint to the player to show that they need to throw the rock there in order to start the chain of events. I created a script and added it to the game object “BoulderHold”. It can be found below:

Screen Shot 2018-03-15 at 13.45.08

So, this script will activate when the rock hits stick holding the boulders in place, once the contact happens both game objects will be destroyed causing the boulders to start moving. This is the start of the chain of events and will cause the broken tree to fall on the tree with the fruit on. Due to the positioning of the “BoulderHold”, the player will need to climb back up the ladder and out of the way in order for the event to occur.

The first problem I encountered was the positioning of the custom when placing it down on the movable platform. It caused the platform to move down but then rolled off the edge onto the game floor, meaning it no longer acted as a counterweight, which meant the fruit hit the movable platform and fell off the map (this will be water when art work is in place). To fix this, I gave the platform a polygon collider (instead of edge) so I could manipulate the edges of it. I moved the edge on the far left up slightly past the bounds of the sprite so the custom will stay on the platform. An image showing this is shown below:

Screen Shot 2018-03-15 at 13.54.19

I then ensured the masses of the objects were different and slightly realistic so the events would occur properly. The masses of the objects in order of heaviest to lightest is shown below:

Broken Tree > Custom > Fruit > Boulders

Once these were all in place and all the correct bools were in place in the scripts I ran the level and the fruit was able to fall to the game floor. The video for the test can be found below. All that is left for this prototype is the artwork.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s