0 votes

Hey, I am developing a 2D city builder style game inside Godot. Currently, I have Over 40 area2Ds every game, due to people being able to spawn in a building with four of them each. However, the Buildings are constantly checking for other buildings they are colliding with. I am afraid that this will cause large lag problems in the future. Is there any way I can check for area2D collision from a function call instead of every frame?

For example, can I use a function that checks for a collision once? Instead of Area2D checking every frame.

Currently, I am using the Area2D_entered(area): function

Thanks for the help :)

Godot version v3.2.3.stable.official
in Engine by (15 points)

1 Answer

+1 vote
Best answer

In my tests I've used Areas_entered(area): for over 300 agents in 3D without any noticeable fps drops.
You can however use Area2D's get_overlapping_areas() function which returns an array of areas within the bounds of the Area2D its called from

by (6,264 points)
selected by

Oh ok, Thank you. Sorry for the late response. I didn't know get_overlapping_areas() was a thing. And it's great to know that there shouldn't be an fps drop. This is super helpful. Thank you :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.