As I understand it, physics constraints are the ideal way to attach a pick-up to a VR controller (Actor) while retaining the inability for the player to make the picked up object from clipping through walls. However when I try to set a constraint to the controller actor, the mesh will not move at all with the controller.
Current code/setup is as follows:
AStaticMeshActor with UPhysicsConstraintComponent and PickUpAble Tag
AVRController Class derived from AActor
I have tried reversing the Actors in the SetConstrainedComponents and the behavior is the same.
void AVRController::Grab()
{
if (m_b_can_pick_up == true)
{
if (m_pick_up_actor != nullptr)
{
// Works but clips thorough objects. See below video
//m_pick_up_actor->GetStaticMeshComponent()->SetSimulatePhysics(false);
//m_pick_up_actor->K2_AttachToActor(this, TEXT("Trigger"), EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, false);
UPrimitiveComponent* pick_up_actor_cast = Cast<UPrimitiveComponent>(m_pick_up_actor);
m_pick_up_actor->m_phys_constraint->SetConstrainedComponents(m_vr_controller_mesh, NAME_None, pick_up_actor_cast, NAME_None);
}
}
}
Here is a video of the not desired output