Due to the lack of Internet connection, the rest of development that was done so far, but hasn’t been talked about is included in this post.
Button plate
Button plate is similar to the pressure plate featured in previous posts. It’s purpose is very similar however instead of deactivating when the player steps off, it stays on. To deactivate it, player has to step on it again.
Moving wall
This is pretty much a carbon copy of the moving platform, accept it is not made for the player to ride on, so the script has to be different, therefor it is made as a separate object. You can see it on the gif showcasing button plate.
Button
Button has been finished as well. Originally it was going to be done through the use of triggers and detecting if player was close to the button and only then registering the input of “E” button. However, it turned out not to be the best way to do it. This was because in order for it to work, the event of the code checking if character is in range and player pressing “E” button had to be done at the same time and if not, it just wouldn’t work, or at least, I think that what the problem was. Never the less, it has been changed and I instead detect if the button can be activated by doing a raycast (kind of like a laser) of a limited length from the view and making the button it hits “active”. Each button checks if player has pressed “E” key and if it is active, if both are true, the button then gets activated. If not deactivated, the button deactivates after a short period of time.
Example bellow shows button being pressed which activates the the cube, but then after few seconds it gets deactivated.
Lever
Lever is very similar to the button and I have encountered the same issues make it as I did making the button. The only difference is that a lever doesn’t deactivate itself after a short period of time. Instead it is pretty much an on/off switch that player can activate and deactivate.
Actor-Reactor
First of all I had to rework the linking functionality of actors and reactors. Originally an actor, let’s say pressure plate was able to activate multiple reactors, like two different moving platforms. However, I made a decision to make to also sometimes require multiple actors to be activated in order for a single reactor to respond. This would allow me to require player pressing two buttons, before a platform would move. However, because of the way I went about it, I lost the ability to activate multiple reactors with a single actor. So I had to rework it for the second time. It is now in it’s final version works by using a linking script that links multiple actors to a reactor, which allows a reactor to require multiple inputs. Each reactor can the have multiple links connected to it, which allows to have multiple reactors be activated by the same set (or single) of actors.
Door
The door and trapdoor were one of the most difficult ones, since I used animations to open and close them, which I don’t have much experience with. When it come to which one was more difficult out of the two, it is definitely the door. The way I wanted it to work is that when player activates it, it would start opening, which easy enough you just play opening animation. However, if it is deactivated before it is fully open I needed it to close. In order to do that I couldn’t just play closing animation, nor did I want it to finish the opening animation. So I had to figure out how to make it stop in the middle of animation and then play the next one based on where the previous one had stopped. It took me while to figure out with many iterations of errors. The one shown below is when I start to figure out how to play an animation starting at a given animation time, however as you can see I didn’t quite understand how it worked and it ended up jump up instead of opening.
I have managed to fix it in the end and it is now working as can be seen below.
Trapdoor
Trapdoors were a lot easier once I had figured out how animations work. All I had to do to make the trapdoor work then is to detect when player lands on it, play opening animation, make it wait for few seconds and play closing animation as shown below.
While I did have to make some adjustments like disabling the collider after the closing animation started playing, this is the feature I had the most fun with after it was developed, since it on it’s own can be a fun jumping mechanic.
This about sums it up for the features developed.
0 comments