Asylum – Developer Diary Day 23

As I mentioned yesterday I was having some difficulties working out how to locate and change elements on the GUI from the trigger object (for testing purposes the first door).

Fortunately I have now solved the problem. It turns out that in Unity you cannot ‘gameObject.Find()‘ an inactive game element. So it was impossible to locate the GUI panel that is hidden/inactive by default. After working out that this was the case I turned my attention to the main container object for the GUI which is always active. I could then attach my script to the root element and using the door for testing I was able to get the door to tell the GUI Root to change the title label to display ‘Door’ when the door was activated – which would be how other objects in the game would react.

Obviously this all sounds rather trivial but it is extremely important for elements later on.

The next challenge was to work out the best way to pause the game, display the mouse cursor and allow the player to interact with the various panels that might be displayed. This took a bit of diving into C# scripting to find out what I needed to do; not something I really wanted to look into but I didn’t have much choice in the matter; fortunately the C# needed to pause the game and unlock the mouse cursor was a simple ‘if’ statement and some basic function calls. Phew!

With that all sorted and ready for later on I returned to the actual gameplay and realised that I needed to add some more doors and cells to the first floor. This is when I hit another small issue. The door script I’d created was fine providing the door wasn’t flipped round. Now it’s obvious that a building would have door facing both directions, but in a game world things get a little harder. So, tomorrow I’m going to be replacing my doors and door script with an animated version, this will eliminate the problems I’ve been having with the door swinging constantly round and round regardless of the wall 🙂

I also hope to add in the first object that can be examined so I can fully test the UI I’ve put together.