#Room collision system ?

9 messages · Page 1 of 1 (latest)

shell talon
#

Hey, how can I do a collision system in which the player has to remain on this collision polygon I created ? I thought about using it from get_parent() in the player class but it doesn't seem to work

I also believe the "in" operand is for arrays but it's something like that I am trying to do : we check if the new position can be accessed by the player and they go there if they can or doesn't if they can't.

I also tried to store the current collision map that I'd update on each room change but still, I have the "in" problem, can anyone help on this one ?

hidden jolt
#

Geometry2D has a function to check if a point is within a polygon , you can use that to check if the new position is inside the room

#

however that is for Polygon2D, don't know if you can make it work with collision shapes

shell talon
#

Oh okay, it might be even better to have a Polygon2D I think but it always returns false now, is it done correctly like that ? position being the player's position and velocity being the current added value to that position

wicked wadi
# shell talon Hey, how can I do a collision system in which the player has to remain on this c...

is there a reason why you don't use normal collisions? in 2D, the normal approach is using TileMaps. Your tiles can have collisions, keeping your player out of them.

What you are describing is exactly the inverse. You want to keep the player inside instead. But both approaches would end up functioning in an equivalent way. I currently don't see a good reason for doing it the way you want to do. If you start implementing custom logic like that, Godot functions for autopathing/AI logic/projectile interactions with the map etc may become unusable.

In other words, you seem to be solving a simple problem in a roundabout way that will cause a lot of problems later on

shell talon
#

Oh okay, I'll give the TileMaps a try then, I didn't really know how to use them

#

Thanks for the help

wicked wadi
#

np

wicked wadi
# shell talon Oh okay, I'll give the TileMaps a try then, I didn't really know how to use them

If you don't know where to start, I advice Brackeys tutorial. You should watch the whole 1 hour, but I timemarked where he talks about TileMaps https://youtu.be/LOhfqjmasi0?si=6dLdcY-xA9Jn8UV4&t=1018