+1 vote

I am working in Godot 3.0 on some utility functions to use in my enemy state logics.

I want to write a function which determines whether the platform the enemy is standing on is connected to the platform the player is standing on.

enter image description here

My platforms are StaticBody2Ds with either CollisionShape2D (rectangle) or CollisionPolygon2D children.

It's easy to get the platforms the enemy and player are standing on. I just raycast down and create references to the colliders.

But how can I determine whether these two platforms are connected?

How can I determine whether there is a chain of StaticBody2Ds connecting two StaticBody2Ds?

Could something be done with GraphNodes? Maybe manually creating a graph on top of the platforms with connections between the platforms being represented in the graph? I'm not sure, since I've never used the GraphNode and I don't know how it works.

in Engine by (1,602 points)
edited by

Maybe you could try putting an area2d with a polygon collision shape above all contiguous series of platforms. Then when the enemy and player are both colliding with the same area2d they're on connected platforms. Could be a ton of work depending on how big levels are though, there is certainly a better way.

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.