top of page
Search
Writer's pictureKieran Boyce

Door Cut-scene

Updated: Mar 28, 2020

The next task was to create a cutscene in which the player presses a button and opens the door. So, the first task is to create a door i did this by using 6 cubes and shaping them so I could create a nice animation for it opening and created a building of sorts the end result looks like this.


Next was to create the button which I did using cylinders and reshaping them. the button itself I parented to the cylinder it was located on to make it easy to find.


Next I created 2 new cameras one which would view the player pressing the button and the other one was there to view the door opening. Now almost all the correct pieces are ready to get this working the final thing i did was create a trigger in front of the button so that the player can only press the button in the trigger.


Now that all the pieces I need are together I first animate the door. To do this I create an animator for it and then create 2 new animations for it. the first one being an idle animation and the second one being the door opening. The idle animation for it is simple as it can just be the door not doing anything. however, the open animation is a bit different I had to set the position of parts of the door at different key frames for the animation do that they would open how I wanted.

Next was to go into the animator and set the conditions up for the door to open. All I need here is an open bool which I can set to true when i want the door to open when I write the script for it to open.

For the script first variables need to be created so we need a few for the different cameras in the scene, a few for the animators and the player as well as the button and the door itself, and a Boolean to check if the door is opened.


Next is to set the player in the awake function this is so I can access the collider in a minute. next is to create a function called onTriggerStay and have it take a collider.


What this function does check if a collider is staying inside a trigger there are also other variants for this function for entering and exiting the trigger. This function is where most of the code will be initiated. But first I create 2 Ienumerators the first one for the door opening in that I set the door camera to active and get the animator to set the opening bool to true after this I have a wait for seconds so there is enough time for the door to open and then the set the camera to false to deactivate it.


Next is to make the door open function in here I set the camera for the button press to true as well as set the players punch animation to true so he punches the button. then after half a second I set the buttons z position to move slightly to create the pressed button effect and then set the camera for the button press to false and starting a coroutine using door open which activates the code for the door opening. and then that is it for this.


After this I head back to the onTriggerStay function, in here I set the colliders and animators up and then check if the collider inside the trigger belongs to the player, and then if it does I then check if the correct button is being pressed. Then if that is true open is set to true then we check if it is true which it should be after its set to be true then we start the button press coroutine which begins the whole process.


I also added in a check to see if the process is finished with the finished Boolean so that the player can only do this once as I had a problem where the player could keep activating the event after it finished.


The final thing t do was add the script to the trigger and then all should be good.


After testing I noticed that the player could activate the trigger from any angle so to sort this I decided to change the player's rotation to face the button as the process begins it looks a lot better like that.



I thought that this feature worked quite well the door cutscene was quick and didn't drag on too much so gameplay could keep running smoothly, sort of like in ratchet and clank when the cutscene is only a couple of seconds.


There were a few things I believe I could have done to polish this feature up. One of these things being that the player is able to still move around in the cutscene which could be dangerous in levels where there are enemies about or obstacles that the player could fall off of. as well as this when the player triggers the cutscene they are automatically put in the correct position so if the player was facing away from the button they would be able to press the button.


Here is the finished product.





5 views0 comments

Recent Posts

See All

Comments


bottom of page