unity3d: 2. Procurement points, respawn

Hi, today I will show you how to capture points and make respawn to next level after captured all points, to work!

I will introduce a simple method, on start, check that simple code below:

First we have to add library on the top using UnityEngine.SceneManagement that we could use function from that library SceneManager.LoadScene („level1”); which it serves to loading the level. In quotes we have to enter name level, which we would like to move. I don’t have an idea so I called it level1.

Next we have got variable impediments, which to keep is number of impediments, variable impediments is static, so all object will be see how much objects is still in this level. Further is variable points, that variable representing how you think out number points.

Function OnTriggerEnter will execute when will to take place collision with player with object, using that function you must also check in object which serve for impediments function IsTrigger.

Next instructions means this same what points+=points + 10; so when to collision will succeed then quantity of points will be larger about 10 points. Next line it means that same what previous line only variavle is impediments. In next two lines are display values both variables in console. Next line are destroing which player to collided with. Farther is variable impediments will be eaqul 0 player goes to next map. If you want to move to next map, you have to move to bookmark file then Build Settings and drag and drop map to window Scenes In Build map which you want to move.

This content also you can find on steemit: https://steemit.com/unity3d/@slawas/unity3d-2-procurement-points-respawn

And on medium: https://medium.com/@sawomirkowalski/unity3d-2-procurement-points-respawn-b6c9dd4800cb

That’s all, maybe this isn’t perfect but on begining is good, see you later!

If that post was useful for you share it with your friends :)

Post a comment

Be first!

Notify about