Relative Content

Tag Archive for collision-detectiongodotgdscriptgodot3

`.is_in_group` method not returning `true` despite being used on an object inside the specified group

I’m making a roguelike game in there is a large, procedurally generated level. There are loads of enemies in the level, and in this case they will only be aggravated and start attacking once you get within a certain range of them.
So to do this, I create a CollisionShape2D in the main scene. I name it ‘AggravationRange’, and I put it in the group ‘AggrivationRangeGroup’. I then also add a Sprite2D as a child, so that I can see how large the parent CollisionShape2D is whilst inside the game. Then, right after I add the player to the main scene, I create a variable referencing the player node, then making it so that AggravationRange is always at the same position as the player. I do this instead of simply adding AggravationRange as a child to the player, as it prevents the rotation being changed also.
Next, I open the script for the enemy and add an _on_area_entered() signal. The code I use for it: