Unity Apk size is too big for building the same scene

I’m Developing a game that should have 15-60 levels when all the environments of the levels are the same. I created a scene (level1) and tried to build it the total apk is around 38Mb which is fine. But When I duplicated this scene to create the other levels and build my game the file size jumps to 148Mb which is problematic for me.

Things I tried:

  • I Optimized meshes, textures, and audio files.
  • I tried toggling static batching, SRP batching, GPU Instancing.

Here’s some of the editor log of the second build:

Build Report Uncompressed usage by category (Percentages based on user generated assets only): Textures               6.2 mb    1.8%  Meshes                 3.1 mb    0.9%  Animations             781.3 kb  0.2%  Sounds                 0.0 kb    0.0%  Shaders                1.8 mb    0.5%  Other Assets           652.6 kb  0.2%  Levels                 323.1 mb  91.6%  Scripts                3.6 mb    1.0%  Included DLLs          13.4 mb   3.8%  File headers           105.1 kb  0.0%  Total User Assets      352.8 mb  100.0%  Complete build size    678.6 mb Used Assets and files from the Resources folder, sorted by uncompressed size:  2.2 mb  0.3% Assets/Polygon/PolygonSamurai/Models/Characters.fbx  1.2 mb  0.2% Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/UberPost.shader  1.0 mb  0.2% Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF.asset 

I’m sure I’m doing something wrong I don’t know where is the main problem. Any help is soo appreciated.

Prevent Unity From Loading The Next Scene After Getting to the Final Scene

I’m a beginner in Unity, I wrote a script that will load the next scene whenever monsters in a scene are dead. The script is working fine. Here’s my script.

public void Update() {     if (MonstersAreAllDead())         GoToNextLevel();  }      //Loads The next Level After all the monsters are Confirmed Dead  private void GoToNextLevel() {     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);      }  

However, I only have two scenes in my game and When Unity gets to the final scene, it displays an error since there is not next scene to load to.

Scene with build index: 2 couldn't be loaded because it has not been added to the build settings. To add a scene to the build settings use the menu File->Build Settings... UnityEngine.SceneManagement.SceneManager:LoadScene (int) LevelController:GoToNextLevel () (at Assets/Scripts/LevelController.cs:39) LevelController:Update () (at Assets/Scripts/LevelController.cs:30) 

My question. How do I tell unity that it should stop trying to load the next scene and instead Display a message to the user? The message displayed can be something like "This is the final scene".

Thank you all in advance for your answers.

Why when I move the transform closer to the target by dragging it in the editor in the scene view the target start stuttering and moving back?

The script is attached to a transform that move to a target and than when reaching the target the transform become child of the target.

The script is working fine as it is now but if I drag with the mouse in the editor in the scene view the target to the moving transform while the transform is already moving to the target then the transform start stuttering and even moving back a bit like pushed back some forces pushing it back maybe because I’m using lerp in lines 55,56 ? I want to use lerp but maybe it’s making the problem?

Second if I move the target away from the transform instead trying to chase me and reaching me its doing this problems again.

I want that if I’m dragging and make the target closer to the moving transform than just keep the transform moving to the target and become child when they reaching each other and if I drag the target away from the transform make the transform try to chase me reach me and become child too.

using System.Collections; using System.Collections.Generic; using UnityEngine;  public class MoveToTarget : MonoBehaviour {     public enum TransitionState     {         None,         MovingTowards,         Transferring     }      public Transform destinationTransform;     public float speed;     public float lerpTime;     public bool isChild = false;      public AnimationCurve curve = AnimationCurve.EaseInOut(0.0f, 0.0f, 1.0f, 1.0f);     public Transform start;     public Transform end;     public float duration = 10.0f;     private float t;      private Transform originTransform;     private float timer;     private TransitionState state = TransitionState.MovingTowards;     private Vector3 originTrans;      void Start()     {         t = 0.0f;          curve.postWrapMode = WrapMode.PingPong;         originTrans = transform.position;     }      void Update()     {         switch (state)         {             case TransitionState.MovingTowards:                 var v = destinationTransform.position - transform.position;                 if (v.magnitude < 0.001f)                 {                     state = TransitionState.Transferring;                     originTransform = destinationTransform;                     timer = 0;                     return;                 }                 Vector3 moveDir = v.normalized;                 //transform.position += moveDir * speed * Time.deltaTime;                 t += Time.deltaTime;                 float s = t / duration;                 transform.position = Vector3.Lerp(originTrans,                     destinationTransform.position, curve.Evaluate(s));                 break;              case TransitionState.Transferring:                 timer += Time.deltaTime;                 this.transform.position = Vector3.Lerp(originTransform.position, destinationTransform.position, timer);                 if (timer >= 1.0f)                 {                     this.transform.parent = destinationTransform;                     isChild = true;                     state = TransitionState.None;                     this.enabled = false;                     return;                 }                 break;              default:                 this.enabled = false;                 return;         }     } } 

Godot Engine: Why is baking light making my scene darker?

Apparently I don’t understand real time lighting. I have an interior scene with some windows. The light is from an OmniLight near the ceiling, default environmental light from outside, and a desk lamp with emission. Without baking light, the scene looks like this:

enter image description here

Consistent with the documentation for emission, the desk lamp is not affecting the surrounding objects. I want to bake the light to see the lamp’s effect and to support low end hardware.

I followed the baked lightmaps tutorial and set the BakedLightmap’s extents to encompass the entire room. After baking, the scene looks like this:

enter image description here

I can see the lamp’s light, as expected, but now everything is too dark. It is unclear to me from Godot’s documentation if scenes include indirect light without baking. I have tried this with the OmniLight set to bake "all" and only indirect light.

What am I missing here?

Mirror Create Player From Client and Change Scene

I’m very new to Mirror in Unity but I have a lot of experience in Network-programing.

I’m currently trying to create a Game, where the Player’s data is stored on the client, and can join different games (not concurrent) with his/her character. (Likely to Terraria)

So I can’t use the automatic Player creation of the default NetworkManager class. After clicking "Join/Host" in our Main-Menu I want to change to the scene the player has played in, Hosting/joining a server and create the player on the server with the specific position…

I have tried now multiple attempts to do this, but none of mine seemed to work. Am I the even possible to have the players in different scenes with ease? Where/When should I create the Player so isn’t null on the Server?

Load new scene unity?

How do I load the next scene in unity when my player hits a 2d sprite?

This is my current code –

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;  public class Loader : MonoBehaviour {     public Animator sceneChange;     private Coroutine _loadInProgress;       void OnTriggerEnter2D(Collider2D other)     {         if (other.CompareTag("End"))          {             Debug.Log("END");             LoadNextLevel();         }                     }      public void LoadNextLevel()     {         if (_loadInProgress == null) {             int nextLevel = SceneManager.GetActiveScene().buildIndex + 1;             _loadInProgress = StartCoroutine(LoadLevel(nextLevel));         }     }      IEnumerator LoadLevel(int LevelIndex)     {         sceneChange.SetTrigger("Start");         yield return new WaitForSeconds(1);         SceneManager.LoadSceneAsync(LevelIndex);         _loadInProgress = null;     } } 

Where do I put this code so that when I collide I load the next level?

Rendering overlapping normal map textures to a 2d scene efficiently

I am using modern OpenGL to render a 2D non grid/tiled world map. I’ve generated some simple normal map textures to render over the base world map to provide terrain elevation/detail shading. Terrain is not tiled (triangulated from noise), so the majority of these terrain elevation features can overlap. This is good as it gives a more continuous appearance to mountains etc.

However the normal map shader needs to sample the base terrain color and apply the lighting value to it before returning the output color. So I can’t render two overlapping normal textures without the second ‘cutting out’ the first where they overlap (the second texture render cannot see the output of the first).

My solution to this was to use a 3 pass render to texture via FBO. I attempt to divide the normal textures destination locations into 3 non overlapping groups and render 1 group in each pass. This works to a point, but of course where a texture overlaps more than 3 neighbours the cut out problem remains.

I could just increase the number of passes/groups to 4, 5, 6… and perhaps this will resolve most cut out issues. While this would probably still provide reasonable performance on my system I am guessing there is a limit where integrated graphics cards may struggle.

Is there an alternative solution for this that could scale better to lower end systems? Or is perhaps even a 5 or 6 pass full-screen render viable on even integrated graphics these days?

Note:

The first render pass draws the entire 2D scene (minus terrain shading) and is obviously the slowest, but it happens only once. The remaining passes make a screen size copy of the previous pass to a second texture (rendering to a screen sized quad) and then render normal textures to this copy using the first texture as input. Adding more passes would only repeat the screen sized texture copy and normal texture rendering.