Tuesday, November 18, 2014

PPP3 - Unity Workshop #2


- Now we want to animate a door to open and close when triggered.
- In order to do this we need an OnTriggerExit script line added to our previous script with some modifications.

- When our Door opens it will move the collider and we don't want this.
- In order to get around this we need to make an 'Empty' object, parent our Door to it, delete the Doors own Box Collider and animate the Door without a collider.
- After this we need to create an animation for the door opening and an animation for the door closing.
- Once again we then need to go into the 'Animator' window where e should have 'OpeningDoor' and 'ClosingDoor' states.
- Here we create an 'Idle' state again and change it to the default state. Link the transition from this Idle to 'Open' state and mark conditions as if: True.
- We then create 2 Transitions again to the Opening and Closing states and change their conditions to match with the bools in our Door script which are: openDoor and closeDoor.


- Next we're making a Light that will turn on when the Player enters a trigger collider through the door.

Enables Light when entering Trigger Collider
- We tried to get a Light Switch working but for some reason it wasn't working. The WIP code is below though:



- On the bright side it includes 'GetKeyDown' commands, and I learnt from it how to create a Debug Log to check actions of the script.

! = 'Not. e.g. 'lightOn = !lightOn;'

EDIT: Updated Light Power script working as intended.
When In Range > Able to Press Button > Turn Light On.
When Out of Range > Button Press has No Effect.


- Random Generated Rooms = Look at 'Arrays'.



No comments:

Post a Comment