godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.21k stars 21.04k forks source link

VR controllers have collision issues #69363

Open Blockyheadman opened 1 year ago

Blockyheadman commented 1 year ago

Godot version

3.5.1-stable

System information

Android

Issue description

On my Quest 2 Android release of a game I'm trying to make, the controllers don't follow the position its tracked to. I'm using a rigid body so i can add collisions to the controller. it just snaps away from the controllers over time when you lose tracking. Is it possible to make it so we can have collisions for XR Controllers.

Steps to reproduce

make an xr controller, add rigid bodies to the controllers, get result.

Minimal reproduction project

https://drive.google.com/uc?id=1PjT8C8J2kkKQ-e1uPNg1F7f6Y9_kL3iA&export=download

Calinou commented 1 year ago

cc @BastiaanOlij

I don't think you're supposed to have actual XR controllers as RigidBodies, as these move around erratically as opposed to having a smooth motion.

Blockyheadman commented 1 year ago

Well I didn't have the controllers under a rigidbody but rather I had the rigid body under the xrcontroller

BastiaanOlij commented 1 year ago

@Blockyheadman ok this one is very tricky.

XRController is a node that follows the physical location of your hand in relation to a central point in space (the XROrigin3D node).

A RigidBody3D is a physics node whose position is controlled by the physics engine using the velocity of the object, the physics engine tests for collisions along this movement path.

Combining the two does not give you the behavior you're asking for. The rigidbody is still governed by it's velocity, which will slowly increase as gravity is applied and the body will fall away from the hand. At the same time the XRController being its parent will also add the movement of the hand to the rigidbody however as this movement is performed outside of the physics engine, no collisions are tested.

This is not a bug in the system or an issue with Godot, it is expecting a behavior from objects that aren't designed for this. They are doing exactly what they are supposed to do.

If you want a physics body to follow the controller, and either push objects your hand pushes against, or stop movement of the hand when it encounters a static body, then that is behavior you will need to build by having a collision body follow the movement of the hands. It is not a feature that comes out of the box with Godot, it is also a feature that has a level of complexity and specificity to XR that it likely won't become a core feature, it is something that would be implemented differently among different games.

That said, over at the Godot XR discord channel several of us are working on different solutions, some of which we're adding into our XR Tools library. We haven't cracked the egg yet to make this work to the extent that say boneworks does, but depending on your goals there are several solutions that may meet your needs.

My best advise is to come hang out there and ask what others are doing to implement the behavior you're after or check out the tools library and see if it already has a solution for what you need.

Blockyheadman commented 1 year ago

Alrighty. Thanks man. I'll check it out.