Someone told me that destroying game object is actually intense on the device. Is that true? I am developing for iOS. Here is an example script. They said just disabling them would be better.
var bombDamage = 10;
function OnTriggerEnter( other : Collider ) {
if (other.tag == "Bomb") {
Debug.Log("Player hit a bomb!");
GetComponent(PlayerHealth).health -= bombDamage;
Destroy(other.gameObject);
}
}
Well, instantiating and destroying GameObjects does create an overhead, which on iOS can be noticeable especially on older devices.
From my experience, I worked on a platform runner style game, which continuously generated new tile based terrain so on every generation cycle it would destroy 4-6 tiles and create 4-6 new tiles. This worked relatively fine on 4G’s, but would make the game hitch on 3GS devices (and previous to that it would generate larger chunks of terrain, which would hitch even on 4G’s). I ended up reusing existing tiles and simply shifting them around and modifying the textures on them which gave a noteable performance boost.
However, in your case, if you don’t plan on batching many instantiations/destroys on the same logic cycle, it should be fine. Besides, draw calls is something that will give you a way larger optimization margin on iOS.
One advice I can give you from experience though - regularly benchmark your game on an actual device throughout the development, it’s not fun finishing your project, having it run perfect on your computer, only to find out it crawls at 5fps on the actual device
No, I would think that that would be fine… Have you tested it in Xcode to see how well it runs??? If it doesn’t appear to be putting a lot of stress on the device, then I wouldn’t really worry about it that much…
Also, remember to format your code so that it is easier for other people to read it!!!
Try testing it on an actual iPhone and see how it goes!!!