Sunday, 17 April 2016
Craig Lang - Door, Key and Elevator scripts
For the final section of the game the player will need to use a key to open the door to access an elevator. I used and edited previous key and door scripts I've made in the past. I also used the platform script on the elevator which only activates when the player enters the trigger.
I had issues with the door and key scripts as they didn't work properly. The door switch couldn't detect the key script which restricted the door to open. I found out that I didn't call the bool function for playerclose in the door switch script to the OnTriggerEnter function. Once I added it I was able to check whether the scripts were working, which they were. I then figured out that I was using setactive on the key script. When you deactivate an object it can cause issues as other scripts may struggle finding it. I encounted this problem before and resolved it by calling the mesh renderer on the object and disabling that component. This allowed the door switch to detect the key script and therefore can activate the door open script. I had to edit the door open script variables as they were set too low that the transformation of the door was barely noticeable. I also parented both the door switch and door triggers so they didn't interfere with one another. This resolved all issues with the key and door scripts.
I also added a fade out script which turns off a selected light within the scene when the player enters a separate trigger box. I did this by calling the light and effecting it's intensity. Finally I added a OnTriggerExit function on the same trigger which loads the end screen canvas menu. The player can then return from the main menu and will know they have completed the level.
I searched through unity forums to gather scripts for effecting the lights. Even though I was successful due to the light design created by the environment artist it has little effect on the environment.
Labels:
Craig Lang,
Scripting,
Unity
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment