We are currently working on some physics simulations in VR, using the HTC Vive headset and motion controllers. We’ve had limited success using physics handles to simulate motion and throw objects, but they don’t behave ideally. We’ve managed to allow free rotation and inspection of the objects, but objects tend to be really springy and not realistic. Playing with the damping, stiffness, and interpolation values has helped, but quick motions of your hand still cause the objects in question to fly off into the distance and slowly return.
Is there a way to make a physics handle perform more like a proper grab, or will we have to disable physics on the object and make the calculations ourselves while holding them? It would be preferable to find a way to let unreal handle the physics calculations, since it will be more accurate, but we need it to feel much more real than it does now. It would also be nice to keep the handle or something similar so that collision is still calculated.
Here is the relevant code we’re using so far:
Constructor:
PhysicsHandle = CreateDefaultSubobject<UPhysicsHandleComponent>(TEXT("Physics Handle"));
PhysicsHandle->SetLinearDamping(100000);
PhysicsHandle->SetLinearStiffness(150000);
PhysicsHandle->SetAngularDamping(100000);
PhysicsHandle->SetAngularStiffness(150000);
PhysicsHandle->SetInterpolationSpeed(100000);
bPhysicsHandleActive = false;
Tick:
if (bPhysicsHandleActive)
{
PhysicsHandle->SetTargetLocationAndRotation(GetComponentLocation(), GetComponentRotation());
}
Grabbing an item:
SetWorldRotation(HeldItem->GetTransform().GetRotation());
PhysicsHandle->GrabComponent(Cast<UPrimitiveComponent>(HeldItem->GetRootComponent()), NAME_None, GetComponentLocation(), true);
bPhysicsHandleActive = true;
bHoldingItem = true;
Dropping an item:
if (bPhysicsHandleActive)
{
bPhysicsHandleActive = false;
PhysicsHandle->ReleaseComponent();
SetRelativeRotation(FQuat::Identity);
}