0 votes

I have a RigidBody in 3D that has two collision shapes. Once the body reports contacts, say against a StaticBody like a platform, how would I detect which shapes are making contact?

I'm doing this within integrateforces()

So I can get the objects, but I can seem to find what is available from there to resolve which shape is making contact.

func _integrate_forces(state):

    var contacts = state.get_contact_count()

    if(contacts > 0):
        for i in range(contacts):
            get_something(i).i_hit_this_shape()???

I'm overlooking something... Can anyone kindly point me to a method for this kind of query?

in Engine by (5,190 points)

1 Answer

+3 votes
Best answer

So for any future visitors, it's:

state.get_contact_local_shape(i)

Giving it the contact index, returns the shape's index inside the parent RigidBody.

by (5,190 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.