Offscreen stuff causing lag

This forum is currently in read-only mode.
0 favourites
  • Ok so Iw ant to make a huge world map on the same layout much like metroid. problem is,once I get to so many objects the game begins to lag and cause itself to function unintentionally. This has happened to me in 98.9 and in my current version 99.42. I believe because there are so many objects in the game, construct tries to render or do events with them even if they are offscreen. Many of my events have "If Object is onscreen" in them but it doesnt seem to help. Is there any way that we can have objects that are X many pixels away from the screen to not be rendered or scripted at all? In metroid I assume they solved this with their "loading doors" which loaded the next room when entered, which would be nice If construct could do. http://dl.getdropbox.com/u/740832/SMSzil.cap

  • until this is fixed u can take advantage of distance between points expression in conditions to cut the range of which events can run for objects out of range/screen.

  • I don't know if this would save any memory because I haven't tested it out yet but......Perhaps instead of having one massive layout you could have like 4-8 smaller layouts arranged in a grid. Then on your one big layout you would place the 4-8 smaller layouts on the grid dynamically using the layout object. So lets say you are in layout one and you are approaching where layout 2 is visible. Then you would show layout 2 and your player would eventually transition to layout 2.

    Of course this complicates events because you have to deal with layout transitions. The huge benefit is it could make it where only the layout your currently in is consuming memory, but still give the visual impression of a massive layout.

  • yeah with the way im doing this that would definitely make the events more complicated, thanks for the advice though. I havent really played with the layout editor much. Heres my .cap if u want to see what Im talking about. http://dl.getdropbox.com/u/740832/SMSzil.cap

    pretty much trying to remake my own version of a sega master system game. Youll notice that you lag while jumping (hold X) and falling. If you delete a bunch of bricks from the lower area you shouldnt lag. Problem is I need to make a huge map to get that good scrolling transition between areas.

  • Objects already stop rendering as soon as they're off-screen. If anything, I think the "Object is on-screen" condtions could actually be slowing it down. Every time that condition is checked, Construct has to loop through each instance of the object to determine if it's on screen. If there were 1000 tiles, that would be 1000 loops each time the "Object is on-screen" condition was checked.

    I don't know if that's actually you're problem or not, but I'd suggest having only one event with the "Object is on screen" condition and then placing all the events that currently use the condition as subevents to said event.

  • there I posted the cap, once again Im haunted by my inability to make this in construct

  • It looks to be the collision checking for the "Ground" objects. If you turn off the solid attribute, the framerate jumps up to where it should be. I'd suggest placing stretched invisible dummy objects over the tiles to handle collisions. That or use the TiledBackground object for repeating chunks of ground. You have 5895 ground objects.

  • *sigh* how lame, ok I dont want to have to do that but its my only choice I guess. thanks

  • pardon the double post but really there should be an option just to omit looping events for objects offscreen.

  • I don't think a whole lot can be done about it. Construct doesn't know what will be colliding with an object or where it will collide at, so it has to check for a collision with each possible object. Collision checking is already one of the most expensive processes, and doing it 5000+ times every frame is going to take a lot of CPU power.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can you change the collision type of the ground objects at runtime to 'off'?

  • yes you can, and it would probably increase performance.

  • [quote:2v2wzyi8]Can you change the collision type of the ground objects at runtime to 'off'?

    DID NOT THINK OF THAT, god im so damn retarded. Thanks a bunch you guys, once I did this the game sped up ALOT

  • still, you shouldn't have your whole game world (if its big) simulated at once. It's ovekill.

    Not even NES games did it.

    Of course, unless you design really depends on it.... but most don't. Metroid/Megaman/Castlevania doors are a great example of breaking up the world, but if you don't want pauses you could get away with "streaming" the way GTA does it, just load blocks as you're within appropiate distance.

  • I must say i'm a bit surprised that this game lagged. Even if there are many objects, I've allways thought that construct could take really much as long as it wasn't things like effects, physics, etc. This kinda scares me... but i guess there's ways to solve it.

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