give unique size to different CollisionShape2D instances

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AniiKai

I have 2 different enemies in my test game. One is quite similar to the other, so its just an instance of the other enemy with some exported variables that I’ve changed. One of these exported variables is the bounding box size around my enemy, which I created so I can give my enemy random movement while making sure it only stays within a certain range. The bounding box size will change the size of a collisionShape2D I have connected to an area2D so it can tell me when the enemy has left the bounding box so it can begin moving back inside it. The problem that arises is that even though I’m giving the CollisionShape2D different values for the two enemies, all enemies end up with the same size bounding box, that being the last loaded enemies bounding box size. I’ve looked for a while trying to find a fix for this but I haven’t gotten any luck. Can anybody help me out?

My code to set the bounding box essentially looks like this:

export var bBoxSize : Vector2 
func _ready():
    get_parent().get_node("BoundBox/CollisionShape2D").shape.extents = bBoxSize
:bust_in_silhouette: Reply From: Error7Studios

You need to check the Local to Scene box in the CollisionShape2D inspector window.

https://www.reddit.com/r/godot/comments/ljd49i/instanced_objects_interact_as_one_object/

works, thanks!

AniiKai | 2021-02-14 10:16