Just a question about methods for doing this

Master Mobile Game Development with Godot 4: From Concept to App Stores Lession for overlapping platforms with the destroyer.

at the beginning of the lecture i paused it and tried to do the lecture on my own. i normally do this with the lectures. I know in programming there is always more then one way to accomplish the same results. I was just wondering if there was a reason you chose to use a for loop and array for the area2ds that crossed into the destroyer collision shape? i chose to use the area_entered signal as this:

func _on_destroyer_area_entered(area):
	if area is Platform:
	pass # Replace with function body.

Is one method better then the other? and why?

1 Like

The beginner courses (Kaan refers to this one as “beginner+”) frequently have opportunities to make things more performant, and it looks like you just found one.

Sometimes I think he left stuff like this in on purpose just to see what people would come up with on their own =)

1 Like

Yes, this episode was a little over complicated.

  • I did a little different, I actually used the WorldBoundaryShape2D, which is “infinite” so I didnt have to do rectangle in gdscript.

  • I like groups over the collison system, because its clear in the code, meanwhile the “collison table” is hard to see, and easy to setup the wrong way imo.

func _on_platform_destroyer_area_entered(area):
	if area.is_in_group('platform'):
  • Also I really don’t like the name Destroyer, its vague, we are destroying platforms only, so call it PlatformDestroyer :grinning:

The point is its working, I like that sometimes a see ways I wouldn’t imagine, and learning new functions like get_overlapping_areas() , its useful stuff.


nice one for sharing an alternative, didnt even know about the worldboundary option for the collision shape. looks like a handy one that can cover all screen sizes.

cheers for that :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms