The next step in building the game level for the Knightside Chronicles demo was to script the elevator sequence which brings the second part of the game. During this sequence, Caruso will ride the elevator platform up to the upper level, but the elevator will stop at two points during the ascent, where several enemies will suddenly appear and halt the progress of the elevator until Caruso defeats them.
How it works :
At the end point of the first half of the level, the first teleporter object is placed at a distinctive arch for the player to walk through. The teleporter object consists of a gameobject with a capsule collider set as a trigger and a script attached to the object called the teleporter script. When another gameobject enters the trigger collider, the OnTriggerEnter function of the script checks to see if the object that entered the collider was the player character. if so, it then checks another variable called direction to see if this instance of the teleporter object is marked as an entrance or an exit. If it is marked as an exit, the script will then set the position of the player object equal to the position of the paired teleporter object, which will be the exit for the teleporter.The player character will now be positioned at the exit point of the teleporter, which is inside the elevator at the bottom of the elevator shaft.
When the player first is transported to the second part of the level inside the elevator, a gameObject called the elevator controller will manage the movement of the elevator platform and spawn enemies at certain points. The elevator platform consists of the platform mesh and a separate box collider marked as a trigger which extends a short distance above the platform. The platform object then has a script assigned to it which checks if another gameobject as entered the trigger, and if it is the player character which has entered the trigger, it will assign a variable called "activated" a value of "true", meaning that the platform will be active only when the player is intersecting the trigger collider. Also, while the platform is activated, the elevator control script will assign the elevator platform object as the parent to the player character object so that when the elevator platform is moved upwards, the player character will be moved upwards as well. When the platform is not active, the parent-child connection will be removed.
By checking the value of the 'activated' variable of the elevatorPlatform, the elevator control script will then only move the elevator platform up the elevator shaft when the activated variable is true, when the player is standing on the platform. In addition to this, two other gameObjects, called elevatorStop are placed in two different positions along the length of the elevator shaft, each consisting of a short box collider filling the area of the elevator shaft and each one marked as a trigger. When the elevator platform enters one of the elevatorStop trigger colliders, the elevator control script will stop moving the platform and will then spawn 3 mini tumblers on top of the platform. Once the mini tumblers have been spawned, the scripts will then be checking if any game objects tagged as "mini" are currently intersecting the trigger collider for the platform. If the script detects none of these objects within the trigger collider, the platform will be re-activated and the elevator control script will resume moving the platform up the elevator shaft to the top.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.