0 votes

Good evening,

I'm trying to get into the Godot Engine by following the book "Godot Engine Game Development in 24 Hours" from Sams Teach Yourself by A. Manzur and G. Marques.

In Hour 5 there's a sample project "Space Shooter" where several scenes are created. The root nodes are assigned to the scene's group. So the "player" scene has a "player" group.
On the "asteroid" scene a script is applied in which is checked if the asteroid is colliding with the player or a lasershot:

func _on_asteroid_area_entered(area):
if area.is_in_group("shot") or area.is_in_group("player"): 

Now, how do I add the groups of the other scenes? In the group manager the other groups don't show up and if I try to add them manually, by typing their names and pressing add, only the asteroids nodes show.
Groups in Godot

Also, is "area" an in built constant or do I have to define it?
Like the Sprite-'area' of the "asteroid" scene/node is named "spr_asteroid".

in Engine by (14 points)

Did you preload the scene?

1 Answer

0 votes

When you load a scene e.g. the player into the main scene, the player's group should be carried over with it. The group manager should show all the groups that are used in the current scene you're viewing.
Also area is the parameter of area_entered so when that function is called the intersecting area can be referenced using area.

by (3,211 points)
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 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 webmaster@godotengine.org with your username.