Wednesday, 15 January 2014

Rotating Puzzle

A puzzle idea that Joe came to me with was the idea of having objects blocking the path of the player so that they cannot continue until they are moved. The problem is however that they rotate, so the player needs to rotate them until they are at the right angle so that they can then progress forward on to the next stage. I had help with this from our coding lecturer who was in today to show me how to do it. The script written rotates the object, there is not an animation on the object, which was an idea/ possibility in the beginning.


Here is the beginning scene.

When the player walks up to the object, all they have to do is click the object and it rotates to another position.

Each time the player clicks it will change its rotation, the player can do this until it is at the right rotation for them to continue on through the level.

Here is another screenshot of another rotation.

Here is a screenshot of the object behind rotating as well. This script can now be applied to any object that we would like to be able to be rotated.


This code above is the OnMouseRotate script. When the player clicks the left mouse button down, the object will rotate to a 90degree angle. In the Unity Inspector we can choose which angle we would like to be the right angle for the puzzle. Once the player has rotated the object to the right angle, the code then has a target reached function. 


This screenshot above is the puzzle complete code. This works in conjunction with the OnMouseRotate script. So that when all of the objects have reached their target rotation, the puzzle will then be completed. We are hoping to have this puzzle work so that once it is complete it will then open the door for the player to escape.

1 comment:

  1. Definitely going to be helpful, especially when altering the level will take place.

    ReplyDelete