Hi!
I’m developing a space shooter. I’m having problems understanding what codes to use in specific situations, i mean wich are the most effective for mobile.
A specific problem, my bullet deactivates right now in the top of the screen by coliding with a “top screen killer” trigger basicly. Then i found this code:
I get you’re answer and i like it a lot! The problem is that i just wanna write code that is efficient cuse the game runs amazingly but acording to xcode for ios developing it eats my battery like i eat pocorn during Titanic. And there is a lot of small fixes i wanna do just to make the experience better for users.
Seriously, Unity is just heavier to run presently than an equivalent native XCode app.
If you doubt me, make an empty project, build it to phone with a single empty scene, no scripts no nothing.
Here is my results running on a 2017 iPad Air, a project built in Unity 5.6.6:
And here it is in Unity 2018.4.2, the highest version I have on this computer:
Unity is working on it, they have made a teeny bit of progress, and it has a ways to go.
I can however state with confidence that your choice of how to destroy a player-fired bullet at the top of the screen will not impact this in any meaningful way.
Since you deactivate (and not destroy) the objects, i’m assuming you are already using object pooling. If not, definitely have a look at that for mobile. Also, maybe have a look at the new DOTS architecture (ECS, Jobs, Burst) Unity offers, which is a highly performant (and thus energy efficient and useful for mobile) way of writing code. If you use many entities, like bullets, enemies, … then this may be for you. However, be aware that getting used to it may take weeks or even months, as it is not object oriented anymore and thus a lot less straight forward and definitely nothing i’d recomment to a beginner. However, converting small pieces of a project at a time should be possible if you really want to. Like said before tho, if the game runs well i would not over-optimize it. Optimizing can eat a lot of time without any real results to show for it, so if there is no tangible problem dont stress it, and if there is then tackle that specifically.