I’ve been a game developer for 4 years. This was the biggest problem i faced. Please help me.
Let me explain: My game works on Unity editor. There’s no crash, no error. But on mobile (android) some phones crash on level start, some phones have no problems. And there’s no spesific level. Sometimes level x works sometimes level x doesn’t work. I tried 10 different phones and I got different results in all of them. Level1 sometimes works a phone but level2 doesn’t work. That’s change everytime.
Because of this problem, I cannot finish the project we have been working on for 1.5 years.
Please provide the device logs from the devices using “adb logcat”, they may contain error messages that would help to troubleshoot. https://discussions.unity.com/t/699654
The most common reasons for mobile device vs editor behavior changes are:
incorrect loading of assets (eg using System.IO, which is forbidden)
intolerance for script execution order (your scripts don’t tolerate changes in execution order)
just plain old running out of resources, since mobile target memory is far smaller
Adding to Jeff’s suggestions above, you must find a way to get the information you need in order to reason about what the problem is.
What is often happening in these cases is one of the following:
the code you think is executing is not actually executing at all
the code is executing far EARLIER or LATER than you think
the code is executing far LESS OFTEN than you think
the code is executing far MORE OFTEN than you think
the code is executing on another GameObject than you think it is
you’re getting an error or warning and you haven’t noticed it in the console window
To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.
Doing this should help you answer these types of questions:
is this code even running? which parts are running? how often does it run? what order does it run in?
what are the values of the variables involved? Are they initialized? Are the values reasonable?
are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)
Knowing this information will help you reason about the behavior you are seeing.
If your problem would benefit from in-scene or in-game visualization, Debug.DrawRay() or Debug.DrawLine() can help you visualize things like rays (used in raycasting) or distances.
You can also call Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene manually, looking for all the parts, where they are, what scripts are on them, etc.
You can also call GameObject.CreatePrimitive() to emplace debug-marker-ish objects in the scene at runtime.
You could also just display various important quantities in UI Text elements to watch them change as you play the game.
If you are running a mobile device you can also view the console output. Google for how on your particular mobile target.
Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.
Here’s an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:
I might suggest that YOU want to, in order to find out what the issue may be. And please review the logs prior to posting and look for errors and/or exceptions.
I really appreciate for your help. This is Samsung A22 Device logcat and i take SEGV_ACCERR, SIGSEGV signal again. When I research, they said it was related to permissions, but there is no information about unity
@jkkfilmmaker You may need to do a bit of trial-and-error/divide-and-conqueror approach to troubleshooting. Start with a new/empty project and confirm it doesn’t crash. Then add your assets to this new project one at a time until you see the same crash. Also, when did this error start? I trust this isn’t the first time you’ve tested your game on an actual device in 1.5 years. If you can pinpoint when it started, you’ll want to see what assets or code you added around that time. If you are using source control (you should be) then you can revert to a previous build that doesn’t crash, and find the differences.