I have a 3D game, and I added a trigger that loads the next level with a small animation when the player goes through it. It all works fine in Unity editor, but when I build the game it does not load the next level, neither it shows the animation. Any ideas what could be wrong? Thank you!
Hard to say without more detail, but in general it boils down to one of two things. Either the trigger is not firing, or there's a problem with the script.
Try attaching something else to the trigger, maybe something that will enable a disabled GameObject in a position that would be visible when you're hitting this trigger. If that doesn't show up, that tells you the problem is with the trigger.
Otherwise, you have a script issue. The most likely cause is that you're trying to load a scene that isn't listed in the project's Build Settings. Double-check that the scene for the level you're loading is in there, or it won't get built into the project. If the call to LoadScene/LoadSceneAsync is in your script before the call that is running the animation, then if it errors out due to the scene not being available, it would never reach the point where it plays the animation, which would explain what you're seeing.
Related
I'm a beginner in unity and programming, I was following a video for making a Flappy Bird game. Everything works perfectly but when I run the game, I get a floppy disk icon middle of the screen and somehing called DontDestroyOnLoad starts working out of nowhere. I couldn't find or understand anything on google when I search for it. I'm posting the screenshots in case anybody wanna see it.
This icon and dontdestroyonload thing only appears when game is being run:
There's a little button in the type right of your scene and game view called "Gizmos", un-toggle that button, should fix your issue.
Also don't worry, Gizmos can only be seen in the Unity Editor for level editing and debugging purposes --> if you were to build the game, for instance on IOS, they would disappear.
(if this doesn't fix your issue, then I would just create a new scene and copy your gameobjects over one-by-one)
I see someone responded about the main part of a problem, but I'll clarify about dontdestroyonload
Don't destroy on load is collection of objects that won't be destroyed when new scene will be loaded, usually objects there come from running them through DontDestroyOnLoad method somewhere in a script, however I noticed that some time ago Unity creators started to put there some stuff related to built-in tools (like debug)
I've got a player spawning in the scene upon it's start. Using the standard assets, I've dragged the default ThirdPersonController.
However, when I run, although the player spawns correctly, this error comes along.
This is the default script from the standard assets (which I've made no change to).
The way I'm saving and loading the character is with two scripts: [GameMaster][3] and [GameSettings][4] (which are generated along with the player).
Please notice that the default camera that should follow the player is also not working. What am I missing?
Best,
Sporting
I'm trying to load a scene asynchronously so I can have a nice progress bar and I found that the returned AsyncOperation.progress stops at 0.9. I don't have a problem with that but what is happening is that after that, it takes up to 50s to load the scene and that doesn't show on the progress. After deleting some objects I found that there is 1 (the main scene object) that is causing this delay.
My question is, is there any way to load this object in the first 90% of the load (which is happening super fast right now - 1s)?
Thanks in advance
If this GameObject is inside the scene, it is loaded with the scene. The problem you have is with the all script logic inside the scene. The loading thread actually finished, but the scripts, instantieting etc., takes all device resources and it looks like stuck at 90%.
To solve it I think you should delay all scripts executions on Awake or Start methods. That should help, but still all the time needed on particular device to execute scripts will take all CPU, and will look like stuck again.
So, it seems it all comes to the substances I was using. It's really strange for me because I explicity check all of them as "bake and discard substance" which seems to do nothing. After baking all the textures and switch from substance to texture in the material the loading came down from 42s to 1s
I've been developing a board-style game in Unity3D. The main scene is the board, and has the data about each player and the current (randomly-generated) board stored within it.
I intend to add minigames into the game, for example when landing on a particular space on the board. Naturally, I would like to code the minigame in a separate scene. Is there a way I can do this without losing the instance of the current scene, so that the current scene's state is maintained?
Thanks in advance :)
Short answer: no, but there may be another way to do what you want.
A basic call to Application.LoadLevel call will destroy the current scene before loading the next one. This isn't what you want.
If your minigame is relatively simple, you could use Instantiate to bring in a prefab and spawn it far away from the rest of your scene. You can even use scripts to switch to another camera, toggle player controls and other interactions in the scene, and so on. Once the minigame is done, you can destroy or disable whatever you brought in, and re-enable whatever needs to be turned on in the main scene.
You could create a separate scene and call Application.LoadLevelAdditive to load that scene without destroying the current one. As above, you can then use scripts to manage which cameras and scene behaviors are active.
If you're careful, you don't really need two separate scenes. It may be enough to "fake" a scene switch.
Hard to give a complete answer without code, but you should look into the following things either with the unity documentation or youtube:
PlayerPrefs, this is one way of saving data, although i believe it isn't entirely secure i.e. being able to edit from a text file.
Serializable, this is apparently better than playerprefs.
DonDestroyOnLoad, can carry over information to multiple scenes.
Static variables, again not sure if this will help your particular problem.
I'm a newcomer to Unity3D development, and, while following a tutorial to make my first game, I noticed that a few steps I kept repeating as I flipped between the Unity application and my browser (chrome), which were both in full screen, certain steps that I had made would occasionally be reversed when I returned.
The two times I noticed it happening, GUISkins and Scripts that I'd added to game objects had been removed.
Has anyone had a similar problem? To prevent this, do I save the scene or the project? Does Unity offer some sort of Autosave function?
Thanks in advance :)
The changes made to the scene while the game is in play mode will not persist. Once you get out of the play mode, the changes made will be reverted.