Now that we had the light switch working, our next objective was to get a door coded to open automatically when we are are near. This is one thing that I was worried about, at this stage I feel that I should have some sense on how Unity and Coding works, but still it seems lost to me, though by doing the work that has been sent to us, along with the help of the tutors, I'm sure soon, that it will all make sense.
This lesson was all about following what was done by our teacher in order to make sure that the code we had created was working perfectly. We started off by following his every step, every dash, every bracket and every full stop.
Getting the door to open. |
As I mentioned before we followed our teacher Ewan carefully and made sure that we stuck to the script just as he had put it. After we had created the script which is depicted above, we had to go back into unity and drag both the doors on the different drop down menu's now featured in the script. By linking this with a collider, like we had done in the light switch, it means that when we get within a certain area of the doors they will open automatically.
Getting the door to close afterwards. |
This was actually more simple than I thought it would be. It involved us just trying to copy the code that we had already done on the doors opening and pasting it again as its own code. The next thing, using the collider was to say that as soon as the player had left it, we would close the door. Just by changing the numbers to reverse and changing the factors from true to false and false to true, we were set.
We then had the finished result,which was actually quite fun to create. This something that came out quite stunning as you cant believe that computer game designers put this much effort into doing something so small such as opening a door.
The end result. |
As mentioned above, I'm finding coding a bit of a struggle, though today has really taught me new and exciting things which I would love to put into my own level.
No comments:
Post a Comment