Making a Parent Stop Upon Collision of a Child
Asked Answered
E

2

0

I'm trying to make it so that, when grabbing an object in VR, the hand will react to collision of the object. Currently I can push the object through other collidable objects because the object being held is a child of the hand, and so will stay attached to it even upon collision. I have been at this for hours but can't find a decent solution. I've tried using rigid and character bodies, as well as some hacky solution with signals, but nothing so far has worked.

Is there some way to make the parent object recognize the collisions of the child as it's own? As in, can I just combine the collision boxes in some way while the object is being held? Also, ideally I would like to avoid reparenting objects as they're picked up, but that seemed even less likely to work.

Eulaliaeulaliah answered 21/11, 2023 at 14:48 Comment(0)
P
0

Eulaliaeulaliah I don't get why a signal connection is "hacky" here and doesn't work?

You can make a signal be emitted in the child when the collision happens, and then connect that signal to a function inside the parent.

https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html

Maybe provide your signal code so we can see what is wrong?

Edit: You can also make the collision box of the parent work inside the child and vice versa. Just get a reference to a collision box and copy and paste it in the inspector.

Putrefaction answered 21/11, 2023 at 14:54 Comment(0)
E
0

Putrefaction
Thank you for this! I couldn't provide the signal example as I had already scrapped it, but making the collision box as the root node of the object, then attaching that root node to the one of the handcollision nodes from XRTools allowed me to extend the hand collision to include the object. This works exactly as I needed it to, though I may still look for more solutions in the future that don't require making every object have a collision box root, which was required here since having the collision box inside of a body inside of the object's original root node led to some very strange behavior.

Eulaliaeulaliah answered 21/11, 2023 at 17:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.