Topic was automatically imported from the old Question2Answer platform.
Asked By
NVA_Lee22
Old Version
Published before Godot 3 was released.
I want to check if a new instanced scene has collision on its “spawn” position.
How can i do that ? (maybe Area2D overlapping or change from static to kinematic body for collision check?)
What i have:
var myScene = preload(scenePath)
var sceneInstance = myScene.instance()
add_child(sceneInstance)
sceneInstance.set_pos(Vector2(50,50))
# HOW TO CHECK IF THE POSITION IS USED BY ANOTHER BODY?
# if sceneInstance is placed on another object:
# move away OR queue_free()
The Problem now is that i only can check one shape with another specific shape which are declared in the check function. Is there a way to check if the Object is colliding with any other shape of the world (not just a specific one to check) ?
NVA_Lee22 | 2017-07-14 15:55
If are areas, you need to find a way to retrieve them all (grouping them could be the best option), then get the target area’s shape and transform to test against. your design may make things easier or harder.
Some steps to reduce the areas you are checking may be possible, like checking (square) distance to the target point as a filter, or rules for group names according to “zones” (design, again).
So i solved it in another way. After instance alle objects i wait 0.05 sec and run another function in every single object which checks itself for overlapping bodies. For that each object it self need a Area2D and the CollisionShape to get Area2D.get_overlapping_bodies()