instance or objects? the best performance

0 favourites
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • Hi everybody, I have a doubt about the performance in general, and don't just construct2...

    I means, when I'm thinking about how make some objects (sprite) for the games, o for one software, I like to make 1 object and use for many different kind of things...

    it's pretty difficult to explain that (my english is not very good) but, for instance:

    if we make a 2d platform game, you can make some objects for make the gameplay (like a movable platform, enemy...etc)

    now, I'm making a platform in 2d, and I have one object, and this object can be a lot of object (change the frame, the variable...etc)

    now, is better to have one object with 20 variable and 10 frame (and use 40 instances of the same object with different variable on the scene) or make 2 object, with 10 variable and 5 frame and use 20 instance of one and 20 instance of the another one?

    what is the best system to make the best performance? is the same?

    thank you very much!!

  • , perhaps a little too harsh with the "your second language grammar is not as good as mine" banter.... How do you know he wasn't trying?

    Ribis, as answered above - you're much better off keeping your objects and behaviors as separated as you can. It will make your project easier to understand when you look at the event sheets and will make behaviors and instance variables much easier to manage.

  • Ribis ,Colludium,Stiivais

    while its true that its probably easier to have different object, most benefit is when you want to do a compare obj a to b / for collision, placement, and like you said to split things up for behaviors, etc.., and i was always a believer that this was better

    but, i recently have doubts about what gives best performance, i read on the forum, that drawcalls are per object type, but what does that mean exactly?

    does that mean that if everything is in one object there's only one drawcall? does that mean that everything in a family is one drawcall? im leaning toward thinking that one single object would have the best performance, plus you have the added benefit that single objects get spritesheeted, i currently have a good way to work like this, but its more for interface work.

  • vtrix,

    It would be interesting to compare the performance gains / losses between using 1 instance as you say and using dozens of different instances. Without having tried it (yet) I imagine that there's a trade off where the performance gains of one way will eventually out weigh the gains of the other - such that a given layout style and number of sprites will have a range of number of instances that will give an optimum performance. I also am not sure exactly what draw calls are - are they only measured in the debugger profile page or do they also have an impact on collision checking and are indirectly measured in the event analysis?

    I have a couple of embryonic games I'm working on - the intention is that I will ultimately release them on mobile and desktop, providing I can keep my focus (!), so I frequently test them both export options. Even for my most visually demanding scenes I don't see the draw calls using that much of the cpu time (up to 20% of the total cpu demand), so I simply don't worry about it yet. I frequently see that events associated with collision checking and sprite control are the most demanding so they get most of my attention...

  • I have good experiences with instances + diffrent frames set instead of having multiple objects. There are some good articles from ashley about how the engine works and drawing is made.

    You should optimize it only if it is needed. I focus on mobile game apps so I do a lot in that case. If you just want to make browser games I would say you are good for a long time with many objects.

  • I'm noticed that one object and many instances better than just lot of objects.

  • optimizing only when needed, i understand, problem with that is, if you suddenly realize that you need extra performance, changing the way you setup things after doing all the logic is a real pita.

    about testing this, it would be interesting.., most performance tests are just testing how much instances can be generated vs fps

    but lets say generate 1000 instances, with one object and 1000 instances with 50 objects, i think i can test that pretty quick with nickname plugin, maybe i give that a shot later..

  • Here are some results from my testing this....

    So, I made a quick demo. There are 2 layouts, each with 99 custom movement objects of the same image bounded to the screen by obstacles. Layout 1 has 99 different objects while Layout 2 has 99 instances of the same object.

    Draw Calls results:

    99 different objects: 5.8% cpu

    99 instances of same object: 2% cpu

    Now.... when I delete half of the objects on each layout:

    50 different objects: 3.8% cpu

    50 instances of same object: 2% cpu

    So there is quite an overhead for drawing different objects v the same object and a constant and significant minimum overhead on my computer at least for drawing anything on the screen. I didn't have the energy to create different images for each object to see what, if any, that sort of change might make on the draw calls. So, for my laptop at least, although the draw calls demanded 3 x the processing power to draw the different objects, the increase was still only 4% in magnitude - not a problem for most desktop games I am guessing, but such an increase could cause a slow down on a mobile device.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Here are some results from my testing this....

    So, I made a quick demo. There are 2 layouts, each with 99 custom movement objects of the same image bounded to the screen by obstacles. Layout 1 has 99 different objects while Layout 2 has 99 instances of the same object.

    Draw Calls results:

    99 different objects: 5.8% cpu

    99 instances of same object: 2% cpu

    Now.... when I delete half of the objects on each layout:

    50 different objects: 3.8% cpu

    50 instances of same object: 2% cpu

    So there is quite an overhead for drawing different objects v the same object and a constant and significant minimum overhead on my computer at least for drawing anything on the screen. I didn't have the energy to create different images for each object to see what, if any, that sort of change might make on the draw calls. So, for my laptop at least, although the draw calls demanded 3 x the processing power to draw the different objects, the increase was still only 4% in magnitude - not a problem for most desktop games I am guessing, but such an increase could cause a slow down on a mobile device.

    Thanks for the test The results are interesting

  • Colludium , thanx for the test

    so yes, using different objects causes a slight overhead, what i find interesting is that its not a constant cycle, draw calls go as low as 0.1 (same object) and then go back to maximum calls for a while, maybe thats garbage collection and then a redraw is needed, there is also not much difference in using canvas2d for me.

    changing the object size and alpha values seems to take an extra hit, im not quite sure how drawcalls actually work.

  • [quote:9816sj4i]As for that little test of yours - drawing performance isn't what you should be testing here,

    great, you explain your first condescending tone and start another one...

    this was a test on drawcalls with multiple instances or multiple objects,

    but please if you want to put the effort in it, add your test, it would be interesting.

  • thank you all for the reply, maybe I will continue to use less object and more variable/event...

    I made a test and on mobile and is better to make more instance and change the variable to make a "new" object with the same instance (just change the frame of animation and edit the variable of the instance...) in a long time will be difficult, but is better...

    > (my english is not very good)

    >

    Usually i'd try to understand what is being said, but trying to decipher what you wrote... just gives me a headache.

    It's like you're not even trying. >_>

    ...

    I'd say that making many different types of objects for different purposes would be better, as it would be easier to manage and edit, and any behaviors used wouldn't be applied to all of the objects. Probably the same for checking if conditions are true.

    a lot of people understand my post, I don't like to use google translate, I just use for a new word when I don't know how I can say something new, but I wrote the first post in 3 min and for me is a good....

  • Ribis

    if you should want collisionchecking on same object

    you can put the one object in a family and then check between the family and the object

    or use system pick nth instance in a subevent (collision filters 2 instances)

    sytem pick instance 0: do something

    system pick instance 1: do something

    and probably also by variable or uid, ..

  • Ribis

    if you should want collisionchecking on same object

    you can put the one object in a family and then check between the family and the object

    or use system pick nth instance in a subevent (collision filters 2 instances)

    sytem pick instance 0: do something

    system pick instance 1: do something

    and probably also by variable or uid, ..

    yes, this is a good idea to check the collision...

    but for now, the collisionchecking doesn't make any lag in my game, just the Sine behavior make a lag (just for 4 object) when I try on cooconJS with webGL on...

  • thats odd for only 4 objects, you're sure its the sinebehavior? no lag if you completly remove the behavior?

    anyway hard to tell whats causing that..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)