Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KinematicCollision3D.get_local_shape() always returns only the zero index shape #75069

Closed
viksl opened this issue Mar 18, 2023 · 6 comments · Fixed by #99901
Closed

KinematicCollision3D.get_local_shape() always returns only the zero index shape #75069

viksl opened this issue Mar 18, 2023 · 6 comments · Fixed by #99901

Comments

@viksl
Copy link
Contributor

viksl commented Mar 18, 2023

Godot version

4.0 dotnet

System information

Windows 10, Nvidia GTX 1660Ti, Vulkan

Issue description

I'd first like to say I'm not sure if this is a bug or if I'm just understanding the functionality wrong, I've been trying reddit, discord for days, nothing so I decided to come with it here.

I'd like to get the collision shape which collided during KinematicCollision from inside a CharacterBody3D, I found there's get_local_shape(index) method but this method always returns only the 0 index CollisionObject.

If I'm using this wrong I'm sorry, is there some way to use this or something else to get the particular colliding shape?

Test project is in gdscript.

Thank you.

Steps to reproduce

  1. Play the project
  2. Wait until objects collide
  3. Read the output, it prints the first shape only (ChracterBodyShape1)
    The local_shape_at_index prints the shape that should be colliding but it returns only the 0 index CollisionShape3D which is named CharacterBodyShape1, the shape which collided is CharacterBodyShape2
  4. Stop the project
  5. Move the CharacterBodyShape2 above CharacterBodyShape1 in the sceen tree so it's the first child of the CharacterBody3D node.
  6. Play the project
  7. Watch the Output again (again only the first shape this time ChracterBodyShape2 since you moved it up)

As you can see now it prints the colliding shape but only because it's the 0 index shape.

Minimal reproduction project

TestGetLocalShape.zip

@adamscott
Copy link
Member

Be careful, you're conflating the collision_index of collisions with get_slide_collision_count().
collision_index refers to collision.get_collision_count(), the deepest collision being 0.

@viksl
Copy link
Contributor Author

viksl commented Mar 18, 2023

@adamscott I've updated the code to reflect that mistake and updated teh MRP in the original post but as I mentioned previously I did check all the indices manually anyway and they all return a wrong shape. Perhaps I'm still doing something wrong? I really can't get to the colliding shape and only the 0 index one.

Thank you for pointing out my mistake but does it change anything considering the above mentioned, please?

EDIT: I've edited the original post and removed stale info considering the changes, problem is sitll the same.

@adamscott
Copy link
Member

Yeah, something seem wrong. I'll try to put more time on this soon to confirm the issue.

@Raven38911
Copy link

Raven38911 commented Dec 18, 2023

I ran into this issue while working on an own project and also tried the MRP - I can confirm that this is still broken in 4.2.

There is also a comment by @r0401 under the closed (very old) issue #31144, where he reports having the same problem in 4.0.1 and 4.1.

@Belserich
Copy link

Still buggy in 4.3 stable

@adamscott adamscott changed the title Get_local_shape in KinematiCollision always returns only the zero index shape. KinematicCollision3D.get_local_shape() always returns only the zero index shape Dec 1, 2024
@adamscott
Copy link
Member

adamscott commented Dec 1, 2024

Thanks @Belserich for the ping ! I decided to really investigate this time and I found out the issue.

@akien-mga akien-mga added this to the 4.4 milestone Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants