I have checked Google or the Unity Community but no answers to my specific question.
Description of the problem
I am creating a simple game for Android in Low Poly Style and I want to optimize it for this platform. All of my models are made with Blender and there working fine.
I also created a simple house, made of cube with Blender but when the player is near the house, the game lag ! So I decided to make this house with some cube in Unity 3D, to see if it is lagging:
Blue = the player, Red AND yellow = the direction where the player looks
And surprise, the game lag too! And really. I don't know why. As you can see, this is a very simple house. When the player is front of the door and can see the inside house (yellow arrow), the game lag but when the player rotate the camera to see other part of the environment (red arrow), no lag.
Attempt of resolution
I decreased the number of vertices, faces and edges for all of my Blender models including my house but this house is already lagging.
I decrease the side view of the camera player.
I checked the occlusion culling but there is nothing to do.
I recreated a new Blender file for my house but the problem is always here
I also exported my mesh in .obj/.fbx but the lag is always here
My question
What is wrong with Blender/Unity ? What can I do ?
EDIT
Here is a video of my problem. As you can see, when the player see the house, it is lagging but when the house is not visible in the camera player, pfuit, no lag: Link
Profiler
Here is the profile when I play the game on mobile:
Red part -> Player see the environnement, Yellow part -> Player look at the house. I can see in the overview screen the "Graphics.PresentAndSync" increase of 10-15% when the player sees the house. I will check that in detail.
(Posted on behalf of the OP).
I have made the update of Unity 3D to the last version 5.5.2f1 and that solve my problem. I will check if others solutions can be found to this problem and give you a feedback asap but this update make clearly the difference.
Many thanks to all of you :)
To find the real cause of the lag, you should profile your app on Android. See Android part of Profiler window for more details.
Related
I'm using unity 2018.4.14f1 personal (I don't use 2019 or 2020 because it lags my computer)
I'm using the Unity Standard Assets Player Prefab and Cinemachine Freelook for the camera. I have some water, and when my player walks into it, its fine. However, when the camera comes into the water, it stops rendering the water. Is there anyway I can fix it?
Update: I've somewhat got it working, however its hollow when your inside. Is there anyway to fix that?
Video : https://easyupload.io/2b0p3a
(I'm quite a noob so if you need any screenshots please ask.)
The problem here is that the water will only rendered when looking from the outside as the normalized are modeled so. The program renders outs objects that it thinks is not in view. You can load the model into a 3d program and then copy and invert the model to allow your camera to see the water, or I believe there are some shader option to stop this optimization. You can also look in this Reddit thread.
I am using Cinemachine asset in my Unity project and is working fine without any lag. However, the places in my Scene which has a lot of ladders, are facing intense lag, making the game unplayable. Such a scene is shown below.
Reasons that I can think of the lag is too many collisions happening or the cinemachine(may be). Two images below show the physics shape of the ladder sprite.
My camera is set-up inside an empty gameobject called "Cameras" as shown below. The state driven camera utilizes the player animator which is shown in the second screenshot. I am afraid that I can not provide a minimal reproducible example in this case. Could someone help me by pointing in the right direction to fix the lag?
EDIT: Unity profile also suggests that Physics usage is consuming too much CPU with CinemachineBrain.AfterPhysics() and Physics2D.FindNewContacts being the major culprit:
EDIT 2: The ladder is created using a tilemap component as shown below:
Can you try simplifying the collider boxes for the ladder to a single box collider shape?
Before I have real-time lighting because of the performance issue, I decided to do light baking for my 3d game.
So I have mark 3d environment as static because it remains on screen always without movement.
Also changed direction light mode to Mixed because I have few moving game objects too.
But after the baking process gets completed, I got this kind of output:
In above, you can see in the above image what happened with my environment after baking and I have also included light settings if you need it.
You have to enable lightmap UVs in your 3d imported model file.
I got this reply from one Unity forum member so exact wording, I am posting here:
I am experimenting with overlaying augmented reality objects over a pass-through image from the rear camera in Unity.
Has anyone experimented with overlaying objects with accurate tracking? I've tweaked the movement scale to get somewhat decent results but rotation is still not accurate and drift is a big issue.
I've had good luck with the augmented reality sample that ships with the latest tango. in my experience it does work the way you speculated where if you add items to the unity scene they are synced to motion detected by the device.
I believe the tracking and syncing function have improved since you asked this question originally because I've noticed an improvement since I got my tango devkit a month or so ago. there was an update a week or so later, with an immediate improvement.
I have found that some scenes track better than others, it seems to help for there to be additional scenery for it to track. in my workspace, a fairly cluttered apartment, it tracks well but in the neighboring identical apartment unit which is currently vacant and empty, it does not track as well. that could also be a product of the blinds hanging up in my unit that are not hanging up in the vacant unit, filtering out additional infrared.
I'm experimenting with placing 3D objects over the real time input from the Tango color camera.
One problem here is that the hardware color camera 'point' in a (strange) direction. I wasn't able to get the direction vector from the api until now. Your virtual camera for rendering the scene needs this rotation to render 3D objects properly.
There are augmented reality examples of Tango's Unity plugin:
https://developers.google.com/tango/apis/unity/unity-simple-ar
They solve this problem with a matrix that rotates the 3d camera.
It can be found in the Unity script "TangoARPoseController" (C#) that, when attached to a unity camera, rotates it so that it looks at the scene in the right direction. The matrix is obtained in the method "SetCameraExtrinsics" of that script.
Unfortunately, when I apply the matrix to my unity scene it does not produce a perfect overlay (actually it's quiet bad). But I have other sources of position input which may be the problem here.
However, until now I'm not sure if the matrix used in the examples is good enough for accurate ar overlays. Maybe it is just suitable for demonstration purposes. But it should be a good starting point for further investigation.
Are we talking about displaying the 'webcam' in the background as opposed to a skybox ?
Take a look at my GhostHunter repo. It includes a shader and a script for displaying the rear facing camera 'behind' the gameplay objects (like the skybox). It should be useable with Tango and it is better than the 'display on a mesh' technique I`ve seen others used.
https://github.com/NVentimiglia/Augmented-Reality-Ghost-Hunter
I'm developing a 3D game using Unity3D 4.5.2 (free version, not Pro).
I have used a default Particle System to make a Waterfall. I have placed the Waterfall particle system in the scene in such a way that there is a 2D Sprite of a Mountain behind it.
This is to give an impression to the user that the Waterfall is 'falling' out from the Mountain.
However, after 10 seconds on simulating this waterfall particle system, the particles suddenly become transparent, enabling the user to view the Mountain behind it...have provided screenshots below:
So I would really appreciate if anyone could help me out here, as I've looked at a lot of solutions & fiddled around with all the parameters of the particle system in Inspector but to no avail...
To give you the correct answer for this question, I need see your particle system parameters. But I think something is wrong with "Max Particles" amount or "Color over lifetime". Also check "Start Lifetime", maybe it is too much.