Detecting differents zones performance wise

Post any engine-related development questions or issues you are having to receive advice, support, or help.
Post Reply
Firnyx
Posts: 4
Joined: Tue Jul 18, 2023 1:22 am

Hi guys, I want to set two type of zones ( inside/ outside) where light behaviour and others thing will change depending on which zone it is. does setting several collisionpolygon2D (at least 1 for each area) for detecting that in the whole level is ok performance wise ? Or does disabling monitoring and monitorable helps ? currently using segmentshape2D on each entrance to switch, but after putting some I have realised it causes a bug and it might be tedious to use if there is too much. (Using Godot 4.1)

Tags:
User avatar
Tomcat
Posts: 52
Joined: Tue Jul 18, 2023 6:51 pm
Location: Moscow (Orcish Stan), The Aggressive Evil Empire
Contact:

I don't suppose anyone can give you a definite answer to that question. Godot 4 is too young engine and is constantly being optimised. So the most reliable way is to investigate it yourself.
— Who's your enemy?
— The whole world.
— Who's your friend?
— The cat.
User avatar
stayathomedev
Site Admin
Posts: 82
Joined: Mon Jul 17, 2023 2:42 pm

Firnyx wrote: Sun Aug 06, 2023 11:17 pm Hi guys, I want to set two type of zones ( inside/ outside) where light behaviour and others thing will change depending on which zone it is. does setting several collisionpolygon2D (at least 1 for each area) for detecting that in the whole level is ok performance wise ? Or does disabling monitoring and monitorable helps ? currently using segmentshape2D on each entrance to switch, but after putting some I have realised it causes a bug and it might be tedious to use if there is too much. (Using Godot 4.1)
What's the overall construction of the inside/outside setup? Are you only able to go in and out at certain locations?
Firnyx
Posts: 4
Joined: Tue Jul 18, 2023 1:22 am

Dark gray area is inside and light gray area is outside (picture), and I could add some outside area anywhere in the level. I was wondering if putting a big collisionPolygon2D , which would cover all the inside area only to detect where the player is, isn't a bit overkill though it would be easier. I'm a beginner in game dev and I discovered my pc already struggles with too much light effects, so I'm concerned about optimization, but have no idea how much putting collisionPolygon2D cost performance wise.
Attachments
Screenshot2.png
Screenshot2.png (70.58 KiB) Viewed 6771 times
Owen Lloyd
Posts: 30
Joined: Wed Jul 19, 2023 2:37 am
Location: Brisbane Australia

If I understand it correctly you want to know if your sprite is inside or outside and use lighting as required.

This suggestion is simplistic but could you not use an invisible texture (similar to the image you show here) and detect the colour of the pixel under the sprite/cursor position to determine this? Eg black = inside, grey = outside?

I guess that depends on the size of your zone, but if massive perhaps you could scale down the texture and make sure your actual zone has light/dark changes on a multiple. Eg, if detection 'map' is 1 tenth scale, only have a switch between inside/outside on a multiple of 10 and check sprites position / 10.
Firnyx
Posts: 4
Joined: Tue Jul 18, 2023 1:22 am

Thanks for your suggestion ! So If I understand your solution about multiple it's like putting the junctions only at predefined positions as if I was using a tilemap for these transitions, which would allow to check it less often. I like these ideas but I may try to implement them later because I would like to stay with an easier solution for now.
Owen Lloyd
Posts: 30
Joined: Wed Jul 19, 2023 2:37 am
Location: Brisbane Australia

Yes. "Tilemap' is a good way to describe what I was trying to describe! :) And yes, your junctions would be at exact X multiples of whatever ratio 1:X you were using. I hope you find a good solution and please share when you do I would to learn.
Firnyx
Posts: 4
Joined: Tue Jul 18, 2023 1:22 am

Or instead of adding an invisible texture as Owen Lloyd suggested, maybe there is a way to make the player scene know where it is from the tilemap ? And then it detects if it is on the dark gray tile or light gray tile .
Post Reply