NME17AP & NAV16AP
Lukuvuosi 2017-2018
This time we are going to learn how to create death zone and pick up collectibles.
Lukuvuosi 2017-2018
This time we are going to learn how to create death zone and pick up collectibles.
At first we need to create empty game object from top gameobject menu. The object should be placed underneath the floor. Character dies if it drops below the walking platform. We need to add box collider 2D for the empty game object. Be sure that the collider is wide enough that when the character falls, it makes contact with the death zone. Then we are going check the is trigger box in collider window. This enables the use of trigger action in playmaker and makes the collider transparent so that character will not stop when hitting it.
Then it’s time to add FSM to the death zone. Start state will be idle and has an action trigger 2D event in it. When character makes contact with the death zone, the trigger event is sent to the next state. In the next state we are going to use set position action to set character back to the position it started. Put the start values in the x,y and z axes. When you test the game, the character should move back to the start position when it makes contact with the death zone.
Then we are going to pick up some objects. Draw a simple circle in Photoshop and import it into Unity. Add a circle collider 2D to it and tick the option is trigger.
Make FSM for the new object. In the start state we are going to use trigger 2D action. Make a new event for the action and create a new state.
This state has the float add action. Float is a decimal number and we're going to add 0.25 each time object is collected. We are using float because in the later tutorials this number is needed for a different object to work correctly. Create a global float variable called collectible to use in that action.
Last state has the destroy self action. When player comes in contact with the object it disappears.
Make FSM for the new object. In the start state we are going to use trigger 2D action. Make a new event for the action and create a new state.
Last state has the destroy self action. When player comes in contact with the object it disappears.
EXTRA ASSIGNMENT: Make the player parent object to the camera. This is done by dragging the camera in the hierarchy window under the player so that they are linked. Now you need to figure out how to stop the camera from following the player when it falls to its death. And set the camera back to the starting point when the player respawns. You’ll also need to make the game wait for a while before respawning the player.
Ei kommentteja:
Lähetä kommentti