Platform behavior and lag [Solved]

For questions about using Classic.

Post » Thu Jun 09, 2011 2:09 am

Okay, so I'm having some trouble with the platform behavior and a lot of objects on screen.

In the cap, there's 2 layouts. One uses a basic follow camera, the other a sprite with
the platform behavior. The Cam layout with the follow camera will handle 7, 8000 objects
like a champ, with no framerate drops at all. The Plat layout, however, is unplayable.

It only seems to lag when there's more than 2000 objects on the screen. The problem is
that the game is going to exceed that almost always. I know that the random terrain generator is not optimized in it's current state, in that it will fill the whole layout, but it seems that
regardless of how many objects there are over 2000, it will still lag just as badly.

I'm wondering how to fix this, right now I'm thinking writing my own special stripped down
platform behavior, but I'm hoping to avoid that. Or perhaps it's just my computer, I dunno.

Help is always appreciated!


The plat layout has standard platformer default controls. The cam layout uses the mousewheel
to control the speed of the follower. You can destroy blocks by holding down LMB and mousing
over them.

You can download the cap right here.

Thanks!

EDIT: Clarity.
B
12
S
2
G
4
Posts: 44
Reputation: 2,389

Post » Thu Jun 09, 2011 2:38 am

It's because of all the solid objects you're platform object is having to check for collisions with. With thousands of objects, that's thousands of collision checks every frame, which can be incredibly taxing.

What you need to do is optimize your terrain generation. It would be best to only generate solid blocks in spots where it will be possible for the player to collide, and have the rest be non-solid blocks.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Thu Jun 09, 2011 2:55 am

^^
Yeah a good optimization might be the Canvas object. You can paste those objects into the canvas, destroy them, and then update the canvas collision mask. Keep in mind that this will exchange some vram for performance, so use it only where needed.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Thu Jun 09, 2011 3:53 pm

[quote="linkman2004":3ebig9ve]It's because of all the solid objects you're platform object is having to check for collisions with. With thousands of objects, that's thousands of collision checks every frame, which can be incredibly taxing.

What you need to do is optimize your terrain generation. It would be best to only generate solid blocks in spots where it will be possible for the player to collide, and have the rest be non-solid blocks.[/quote:3ebig9ve]

After having slept on it, I came to that conclusion. I didn't think that it would be
calculating collisions for every single object, so I had never tried using less solids.
Very easy to fix, too.

[quote="newt":3ebig9ve]^^
Yeah a good optimization might be the Canvas object. You can paste those objects into the canvas, destroy them, and then update the canvas collision mask. Keep in mind that this will exchange some vram for performance, so use it only where needed.[/quote:3ebig9ve]

I will have to try that.

You both have been a great help to me. Thank you!
B
12
S
2
G
4
Posts: 44
Reputation: 2,389


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests