The Theft Protection

Myths and Facts About Identity Theft

Hi guys. Welcome back to my Unity 3d Puzzle game series. I’m Long In the last part, i made the character follows my character when he moves as you can see here while i’m playing ok, in this part, i’m going to make the “player death state” this means when player hit obstacle or hit by enemy, i’ll place him back to start position Now, create a cube and assume it is a obstacle Reset the position and set Y to 0.75 drag the cube far from my character a little bit rename it now, i need to create an empty game object and name it by startpos reset it’s position and set the one as same as player position. I coppy player RectTransform component from player to the startpos drag and place it here to more convinent, set startpos icon to red color do the same with deathpos now, create a new script to handle this. Name it by DeathPos open it. i don’t need default methods, so delete theme to detect when the character hit the deathpos, i use a built-in method from Unity: “OnTriggerEnter” in this method, i make a condition. If the deathpos cube hit the object which have tag name “player” i’ll set that object position to startpos define start pos here. it’ll be a public transform variable ok, startpos.position here let’s take a try before test, select deathpos object and drag DeathPos script into it drag startpos to here ok, let’s test move the character and make him hit the cube to see what happens Oops, something’s wrong let’s check the code oh, i forget set my character tag to Player test again now the player seem hit the cube, but nothing happens because the character does not “enter” the cube so, set Is Trigger check box in Box collider component it seem ok now. hit play to test yep, you can see the character position is set to startpos when he hits the deathpos cube Soi’ve just done a simple “Player death” state. The character comeback to startpos when he hits an obstacle or death pos. Thanks for watching! Please leave a like and comment if this video’s useful with you .See you in next part.

1 thought on “Unity 3d Tutorial – Puzzle Game [Part 5] – Player Death- longtnh

  1. Awesome! For a little bit of polish, you can disable the player controls until a second after they spawn to stop them from moving forward when you're reviving.

Leave comment

Your email address will not be published. Required fields are marked with *.