• 2D
  • Does ".get_collider()" only returns one object?

Hello Everyone!

I'm working on a 2d puzzle-platformer as a learning project, and so far it's been really fun!

I'm still working on basic movement and animations for the main character, and I was trying to use get_collider() together with is_in_group() to determine the kinds of collisions my player is doing so that I can have it react in different ways dependng on the collider.

But I've "hit a wall" right at the start! Whenever I try to use this method to determine if the player has hit a "wall" with is_in_group("wall") it only returns false if the player is on the ground, and only is_in_group("ground") returns true!

Is it normal? Does is_in_group() only return one collider? If so, what are my options? Should I use raycasting? this way I could setup something similar to @razvanc-r tutorial where he uses one raycast for each direction (up, down, left, right)? I also read on the forums a bit about enter_body signals, would that be useful in this case?

I think these links should help. There are a bunch of approaches. I think there is an easy way to get the engine to do that for you but I haven't used that in any of my projects. I use enter_body to detect collisions in my project, but it doesn't have any walls, just bullets and other objects.

https://github.com/godotengine/godot-demo-projects/tree/master/2d/platformer

This one covers making a tiled map but it has an object that automatically interacts with the environment (didn't rewatch but I think I remember there being some useful stuff in there).

Thank you for the links @bitwes!

What really helped in my situation was to realize I could use only the x or the y from my movement Vector2, and using 0 as the other value, this way I could move or test_move my player in only one axis, checking collisions separately to see if the collider was a wall on the x-axis, or the ground on the y-axis.

I just solved this today during lunch!