Jaimy Magalhaes Coelho's profile

Escape room game: 404 not found

Escape room game: 404 not found
404 not found is a video game project I have been working on with a few other students in the past few weeks. I was one of the two depelopers of this project who was in charge of 3 spesific mechanics and rescheareshed on how to make cinimatics but the result was only half baked. but more on that later. 404 not found  is a game where you are trapped in a room and you are trying to escape so in short it is an escape room game. under here is a short gameplay preview.

(if you want to see my scripting part scroll down)
research on cinematics.
We started this project using the standard unity movement scripts. and first started to see if we could make that work with what we wanted to do. Max my co-developer started to work on an inventory system script and I was given the task to research on how to make cinematics. My research started with thinking about what we have learned so far from school. And I remembered that we had a lesson about unity`s animation window in which you could make certain events happen on a time basis. that included the movement of the camera which is what we wanted. But I also did research online on how to do cinematics and the results of that was different of what we wanted cause all the forums and videos were giving examples of cameras standing still and then things within the camera view that were doing things. and that is not what we wanted. and all those examples required me to learn a lot of new things I have never heard of. So, we settled on using the unity animation window.

Problems: first problem we came across is that for some reason the animation window of unity doesn’t like the standard unity player controller script. We concluded together with the teacher that something in the standard unity script was overriding the animation window functions. Our solution for this was by making our own movement script and that worked better but not completely. This time the animation window was still fighting out scripts but less. eventually we made it work by playing somewhat in the rules of our own script that was overriding the animation window. What I mean with that is that we had to make the animation in the inspector on a different location than where we wanted the animation to be in game. because our script moves our whole animation in one direction a small amount for some reason.

The results where these 2 animations. first one is of standing up from a couch. Second one is one where you get blown away from a door. we wanted to be 3 but where struggling so much and wasting so much time that we dropped the third one.


Here is my Scripting part.
my own player controller script: Because we had problems with the unity player controller script I made my own to fix this.
the movement we ended up with moving with WASD, and looking around with mouse.


movement with input.getkey and transform.translate :this one is straight forward.

camera with rotating quanternion.euler :this one was a bit tricky.
first, I got myself some floats 2, CurrentRotationX and CurrentRotation.Y in other words the current rotation of the camera. then I got some floats for the amount I want it to rotate, rotX and rotY . Next, I got some floats for the velocity or speed I wanted my camera to rotate with a smoothDamp.


line 203 and 204 makes are so even if I stop giving the game an input my camera will still move to the specified current rotation by my script with smooth. which gives a smooth camera effect or better said the camera doesn’t stop abruptly. some people said they didn’t like this effect and others like myself and my co-developer liked it.

line 201 is a function that makes it so that the value of rotX stays between -90 and 90 this is the camera rotation of looking up and down. I did that so that your camera wouldn’t end up upside down.
here a short preview of the camera mehcanics.
Changing of paintings:
the last mechanic I was trusted with is changing of a painting while it is of screen.
first, I discovered a function called isVisible that is a function that almost does what I want. this function doesn’t need allot of fancy extra variables and such it only needs an object that it needs to track if it is visible. But this function considers an object visible when it needs to be rendered in the scene so it could be that it considers it visible when it is not within the camera view.it works this way to prevent the object from not being visible in time if it was invisible so you won’t see it pop up out of nowhere. So, I had to do something else.

and this is what I found. 
In line 89 I needed to know what the exact bound were of my camera. And by searching the internet I discovered that the camera bounds consist out of planes which are geometric shapes.
And discovered I could use GeometryUtility that is a function that utilizes geometric shapes. in this case I assigned every bound of the camera a plane. (this function does the calculation of the size position and rotation of the planes because they already exist within the camera (it is visible within the inspector))

in line 105 to line 133 I have put another GeometryUtility function to use with testplanesAABB which is basically checking if the object in this case grootschilderij_1_coll is within the bounds of the array called planes the .bounds just says that the object needs to be within bounds. and if it is within bounds it changes some bools within my singleton which will be explained later. and calls a function that exist within my singleton that changes the material of the painting object in the game.

here a short preview of the painting mechanic.

Math problem script:
in our game we have a randomly generated math problem which i made the script of it gets generated at the start of the game in the start function . There i called this function called randomSommen. what it does it chooses which math problem in line 155 and gives my 4 variables i use for the math problem a random value between 1 and 9. And then solves the math problem. The answer we use to get acces to a computer in the game. If you want to see how it works  look at the first video on this page near the end .it gets used there. It has a small problem because unity makes it so that when you have a point number it always rounds upwards regardless of the math rules.
Singleton Script:
outside of the mechanics that I needed to make for the escape room game. I made a singleton because I wanted to work with a singleton to learn how to keep things still working if we changed scenes. And I wanted to know if this method of working is comfortable and clear. for the most part everything stayed intact when we switched scenes.

except for my public renders in line 39-41 because everything I have assigned came from the asset folder except the renderers ignore line 27(it is not used).
those where object that where in the scene that in the second scene where from the same prefab but because it isn’t the same object it loses his assignment so it gave me an error when I loaded the second scene that it wasn’t assigned.
I fixed it in line 102-104 by when the second scene starts assigning it via script by using object.find and then the object path that can be seen in the hierarchy.
Escape room game: 404 not found
Published:

Escape room game: 404 not found

A student games project

Published: