Search Instagram Twitter Facebook Spotify Grid Tag Date Folder Chat Pencil

DevLog – Portals 75% Finished

Portals are about 75% finished. Most of the basic functions are now in place. I figured out how to use asynchronous additive level loading with portals, so you can now travel between scenes using Portals. To help with organization of assets, I call portals that work within a scene “IntraPortals” and portals that work between scenes “InterPortals”. The code is slightly different between the two as the InterPortals need to load and destroy scenes and check if the other scene is there already before setting up the connection.

Relativity_Game_Screenshot-2014-02-05_14-03-03

Correct Way to Destroy

On the topic of destroying scenes, I finally learned the ‘proper’ way to destroy gameobjects. Originally, I would just call the Destroy(gameObject) function straight in Update(). This would give me an error problem that I usually just ignored. However, Unity would start to crash when I did this. It was really frustrating, because I would lose everything I didn’t save, and it was a real pain to have to start up Unity again. I decided it would be time to learn the right way.

At first I thought setting objects inactive would solve the problem, but it actually resulted in the same error message. As it turns out, what you need to do is put the destroy function inside a coroutine, and use this line of code:

1
yield return new WaitForEndOfFrame();

Basically, you want to wait until the end of frame before you destroy any objects in Unity.

What’s Next

Today I’m going to start porting the key signal system from the teleportation doorways over to the portals. I still need to test how the additive asynchronous level loading works within a build of the game. There’s a bit of a hiccup when the level is loading when I test it out in the Unity editor. However, the docs say that this is normal, and the editor generally takes longer to load levels than the player.

There’s still several aspects of the Portals that need to be polished, such as when the doors can close and open. There are a few spots where the player can miss the triggers. I also need to figure out a way to teleport objects while players are carrying them.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.