playMaker

Author Topic: Create and destroy for iphone 5 performance  (Read 5105 times)

dougbello

  • Playmaker Newbie
  • *
  • Posts: 32
Create and destroy for iphone 5 performance
« on: July 10, 2015, 04:15:48 PM »
I'm building a game that is kind of continuous, but I need to set each 3d piece mannualy as they are slightly different from each other.

Its kind of a plataformer, just goes in the right direction, but working in 3d.

I'm wondering what is the best way to do this without compromising performance.

Its about 50 3d objects per level and they have animation in fbx... texture, coliders, etc...

One entire level loaded in the beginning is working fine on iphone6 (but this should work for others too: iphone5 minimum)

My idea is to have one null on the position of each object and once the camera trigger pass them, it "create object" and once the camera trigger exits, it destroys self.

I'm wondering if its ok or it is too intensive for performance, the create and destroy all the time.

If there is any better way please let me know too.  ;)

Thanks.
Doug.

HaraldsVeiss

  • Junior Playmaker
  • **
  • Posts: 68
Re: Create and destroy for iphone 5 performance
« Reply #1 on: July 13, 2015, 04:31:14 AM »
Hi,

In my experience the best way for mobile devices is to move objects around than creating and destroying objects.

What I usually do when I am making randomly generated levels or continuous levels that are reproducing further I make that the pieces that move out of the camera view gets placed further in the scene.

What I mean is that when the object leaves the screen I set the objects position in front of the screen view again maybe modify it while its changing position so that it would look differently. This is much less intense than creating and destroying  objects for mobile devices. You can use some creating and destroying but for me it works much better if I just use existing objects in the scene and move/modify them in the game.

Best,
Haralds

dougbello

  • Playmaker Newbie
  • *
  • Posts: 32
Re: Create and destroy for iphone 5 performance
« Reply #2 on: July 13, 2015, 09:56:19 AM »
Yes Haralds, that is exactly what I need.

I started to search for this "moving technique" and I found this thing called object polling that is basically the same concept.

Thanks a lot for the answer!!

Is there also any particular way of planning this levels with this method? I think it must be kind of difficult to build it once you just see them at runtime... (its the same if i would create and destroy) just wondering if there is a technique for building the level in a way you could see it all first.

Thank you very much again.
Doug.

HaraldsVeiss

  • Junior Playmaker
  • **
  • Posts: 68
Re: Create and destroy for iphone 5 performance
« Reply #3 on: July 14, 2015, 03:16:17 AM »
Hi,

Glad this helped you!

It all kinda depends what kind of game you are making. For example if you move your character forward and place your scene objects in front of him that would be a bit different than if character is standing still and you are moving the scene objects towards the character and replace them accordingly.

Generally what I do is, I make sure that when the object is repositioned there are no gaps in between the objects (or if you want gaps between objects than make sure that they are in the right intervals). When you are making the scene, just move objects around, take a look how much does it have to move on x,y or z axes to move in the right place, if you use trigger to move things around make sure the trigger is in the right position so you would get the timing right and so on.

Basically for me its always been more trial and error. I make the system that is repositioning the objects, at first the objects usually are not repositioning in the right spots, than its just a matter of fine tuning the position and timing of the objects. But once you get the hang of it it is quite fast to adjust all the properties.

You might be already doing this but I will say it anyway. Try to make your system easily adjustable. For example if you move many objects on x axes make that the variable in all those objects is easily accessible, so that you have to change variable only one time and it changes in all objects. That goes for the timers and other things as well. That will save you a lot of time in the course of development.

If I didn't explain something well enough don't hesitate to ask more questions.

Best,
Haralds

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Create and destroy for iphone 5 performance
« Reply #4 on: July 15, 2015, 12:33:15 PM »
Hi,

All of this can also be handled by a pool manager of some kind, which doesn't destroy and create but only enable and disable, so on top of what Haralds mention, a pool manager will make the task very easy and flexible.

Bye,

 Jean

dougbello

  • Playmaker Newbie
  • *
  • Posts: 32
Re: Create and destroy for iphone 5 performance
« Reply #5 on: July 15, 2015, 02:19:26 PM »
Thank you guys, this helps a lot... I'm learning all by my self, no mentors or friends to help around here, so every tip and idea gives me a million new possibilities here.

Haralds have a great way of building it, but once I came from a design background, I find easier to position objects by hand and not coding the positions. I think it would be a real nightmare for me to do it with vars x and ys...

Based on his idea, right now I'm creating the levels by hand with copy paste, and positioning the objects, then I group the objects in nulls called "level 1", "level2", etc... this way I can see where every object is on all the levels of the game.

Then I copy this group null for a scene called "level 2", "level3", etc.

I start the game with one level loaded and at the end of each level, on a pause moment, I load the level async, additive. Then I destroy the previous scene null.

It can be dumb, but its working so far.

But with this info from Jean, things can get a lot easier...

So if i enable and disable the objects they won't affect my performance?

Can I load the scene with everything on it and just disable everything is not at the camera (and enable every time)? If this works could be my best option...

Or this just work if I use a pool? Because as I could understand the pool is just a different way of moving objects that are there.

Also I tried to use this occlusion option with unity but it seems to slow things and skip commands, I'm not sure.

So I'm positioning everything and studying ways of letting things run smooth, and you are helping a lot.

Thanks again.
Doug.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Create and destroy for iphone 5 performance
« Reply #6 on: July 16, 2015, 07:02:17 AM »
Hi,

 Pooling would handling all of that for you, the enabling and disabling, so I would suggest you find a pool manager that suits your needs and has PlayMaker support ( like Pool Manager 2 for example).

and yes, enabling/disabling doesn't affect perfs ( to the extend that when enabled your component don't do crazy things that takes time, that's a different issue but would be a problem).


 Bye,

 Jean