Hiding objects that aren't on screen...surely not?

Hello! …I’ve just had feedback on my game ‘Click Track Jack’ …that it would be less laggy if i hid the objects that were not on screen. Surely you don’t need to do this!..
pick all doors
is door on screen …hide
is door not on screen…show
pick all tables
is table on screen …hide
etc

also on the subject of ‘pick all’…is there some sound advice re when and where to do this…as everything i’ve read is a bit vague. I had to use it when attaching the right crab claw to the right crab the other day…and it took a lot of trial and error!

Or, just create a behaviour “hideWhenOffScreen” with the same structure and avoid repeating the same logic for every object.

No it would not

Imagine you have apple in your hand
I make it invisible
And now you can’t see it
Tell me is it

A - you still feel that apple you still need same force in your hand to hold it
You still feel its exact shape

Or

B - you don’t feel it anymore it lose all weight and so there is no energy you need to use it to hold it since it is not there

And same principal more or less goes with hiding objects
You don’t see them but they still getting processed
You would need to delete what is off screen and create it when it is on screen for it to make sense and take effect if it comes to reducing lag

1 Like

Objects are already not rendered when they’re off screen. (Sometimes referred to as culling).

You can go through logic to hide or show your objects, and add a condition to your events that only runs if the object is not hidden. However, this is adding a lot of object picking logic to your project. It could actually hinder performance more than it helps, but it’ll just depend on how much your normal event logic is hindering performance due to things like loops/for each/etc.

There should be no noticeable difference based on rendering the objects, because as mentioned above, objects are already not rendered when offscreen.

Thanks for all your help on this. That apple analogy is a good one. That’s kind of what I thought… and the only way to actually improve lag would be to log all objects as they go off screen, and their attributes in an array, destroy them, and recreate them just before their due on screen…which is a bit beyond my abilities at the moment!

Find someone who can answer this

And i will turn it into chunk system which will allow for de lagging any game
IF you don’t know what chunk system is just check youtube and you will love it after 1st few seconds of any video

this?

I see many ppl struggling at create a working culling system…(i’ve even answered in the Biscuit’s thread about this… i still appreciated he’s works)
In my game i had this fixed long time ago or my game would had never been possible.

i just do this

Explained:

i use the Silver camera Method with player follow and rooms positioning
(the only things you requires are well placed squared proxy box rooms in your game)

The player get the same number variable room for each room.
everything outside (not in the same room or different player room variable is deleted).

I find it really simple…am i forgetting something?
You can even check by rooms collision to creater different culling between rooms…

It works flawlessly in sideview scroller games…but i think iot can be done for everyhting…and i’m proud of it… :wink:.l…joke.
You can even use the same tiled maps for checking.

Just a note: ofc the creation happen when the player enter a room. In games without the camera buffer u may notice the creation for a millisecond.
But it is really not noticable with a minimum of camera buffer.
You can fix this creating a lag between rooms…Like eg to not cull starting rooms, collided rooms to start room ecc…

I 've always wanted this to be an extension…so i can spare som e code lines…
better if some developer would try to turn this ina built in culling method for GD

Ps: i apologize to biscuit to have never said this in his culling thrread…but he was so focused on his work that i ended to let him try. :pray:
The differences is that he’s method use the camera for culling…
I don’t find it as good as it should be because the creations happens almost instantly when in the camera bounduary again and bad behaviours could happen.

PS: maybe this could be integrated in the same Room Camera extension…If approved.

If too many objects are truly the issue then you could divide the game up into chapters or areas.

But, it could also be the events. Having fewer objects might not completely fix things.

Did you use the profiler to see if something is using more processing time?

Wiki : Game profiler

This shows only how to delete something not how to create it
So i fail to understand what you mean

Also i need to split map into grid and use each cell as some area i can refer to
This is base for chunk system where i would load dynamically parts of map and not just objects spamming close to borders each frame

This

I understand…
It will not fit that particular chunk system.
But surely it works for other games, (since i have tested it a lot in mine) if u need a better culling system that destroy things instead to hide em.

this is my creation event.


just as example…(u can create a behaviour for object)…
as i said above the only downside is that if u have a camera with no buffer u can notice the creation cos the timer. (fortunately i have a gamne with fixed zoom and surely you don’t want an enemy at close distance when the player enter a room)
But if u want it is easly fixable if u check differently the var room for the player.

i’ve seen that chunk system…i may be wrong but i don’t find it good for culling bcs it culls in realtime (like biscuit’s method)…if that is what u want…

eg: with real time culling bad things happens if u have for example an object with linked objects, whit the async timers you give the time to read other events…
imo the key for a culling system is there.

PS: this method only works with finite areas.

Do not get it as i am not grateful cause i am
This is in fact helpful
However i am for something more precise
You just create objects you do not save any values they have
And i kinda need to save any kind of values i would need to

And guess what
This is 1st step into chunk system
@Davedorkmouse
I know how to split map into chunks
I only now need a way to give each chunk ID and manage all chunks creation/deletion by ID
Since creating and deleting based on position i already have
So maybe soon enough i will have chunk system to de lag any game

That is fixable.

…I really don’t think of it as a part of a culling method.
But i agree…that have them both…is mandatory in some games…(fortunately not in mine)

Anyway i’ll be the first to test that chunk method if it’ll works. Since idd a culling system solve many lag problems in mosts games.

to Zero.
If possible can you consider to add this chunk system for finite areas too.
I mean it looks like you’re using the camera bounduary system (like biscuits).

This is great for open world games.
If you can eg intergarate a system for finite areas too like eg is inside object area instead of a camera…it would be great.

like an option to chose which object to check or camera in the behaviour.

…basically an improved ver on what i did above

Thanks @ZeroX4 and @RMDB - I’m going to look into this further once i’ve got 5 days of my proper job out of the way! I like the chunk system! …i’ll chew it over while making owls this weekend! seems great for something where crafting and resources are involved like terraria etc . A virtual cellular grid based on players position? my mind is full of half baked thoughts like …could it be based on distance and angle from player and use trigonometry?

@RMDB …i like the simplicity of your system…it’s almost like each room is a mini scene and it’s perfect for dungeon crawlers etc, but it doesn’t seem to allow for things moving around in the rooms or between them…but i like it!
this is something id like to delve into when ive got the headspace as the next game I want to make is procedurally generated …with objects made of other objects.
@Keith_1357 …i did run the debugger …but i don’t know a good stat from a bad…5ms overall with 37% render and 19%events

1 Like

mine is the metroidvania style…in castlevania enemies don’t follow you outside rooms.
Ojects are regenerated each room.

a mix of both methods is what we need

Take a look at the time and percentage that each event uses. It helps if your events are in event groups. See if something is using a large share.

If you’re still unsure then you could post a screenshot or two of the profiler and someone here might be able to suggest something.

what if you had an object without image or behaviours etc just variables…called say ‘holding object’
every 5 frames or so you check if any of your objects are more than say 600pix from player. If so create holding object at that loc. record the id of the object to destroy, size, variables etc in the new holding object. and delete the object.
then every 5 frames or so you check if holding object is within 600pix… create the right object and transfer the attributes and delete the holding holding.

Just because i do not have chunk system it works based of whatever was where to camera boundary

If i be able to give chunks ID’s i won’t be limited to 1st create grid and then give them ID
I could dynamically create grid
So would work for pre-built maps with limited area
And infinite maps with unlimited areas

@Davedorkmouse Here i check if object is off screen where in chunk system i would check if whole chunk is off screen or well on it
I wonder what benefit it would give to have it on player position?
Cause if player is not on screen then what is the point in loading/unloading?
Also angle would not make sense for same reason
Same as position
Since what you can see should be loaded or not
And not what is close to player
BUUUT since i check camera border left and position of object
You could check Player.X() and Player.X()-100 against position of object
Which would check if player is in range of 100 pixels to the left from player
Which stil would not make sense in my eyes

Guy who did teach me how to do this did also this based on radius
But i fail to find usage for it other than it being cool effect
IF that radius would be large enough to cover whole screen seamlessly
Then it would load a lot of tiles for no reason wasting resources

1 Like

Wish u good luck…You’ve got all the right moves. :+1: :+1:
Senza titolo

Stupid question: for chunk…do u mean grid tiles?..
if so…isn’t possible to count tiles based from scene grid size from 0,0?
isn’t assiging an ID for each grid tiles heavy in terms of performances?