Download

How to position Picked up items & Weapons in VR Hands correctly?.

recently got my hands on Oculus Touch & I Already figured out how to pick up custom items I created by using the VR motion controller Template, And using the blue cube blueprints as the core for them.
Only issue is they are picked up in the Orientation I grab them.
But I would like picked up items to automatically just fit in to the correct position in hand when held, Like robo recall manages to do with guns and Broken limbs.
Is it just a case of the Traditional method of snapping items to a custom weapon bone on each hand or is there something more to this?
I cant seem to find much covering this :frowning:

Hi. In my version of PickUp Interface I have a function GetTransformRelativeToHand(EControllerHand Hand). Every pickable object returns a desired offset to hand which can be used in PickUp event: AttachToComponent (Moiton Controller Component), then SetRelativeLocationAndRotation(DesiredRelativeLocation, DesiredRelativeRotation).

It’s C++, but it’s quite simple.
[SPOILER]


bool APlayerPawn::PickUpObject(AActor* Object, EControllerHand Hand)
{
    // Return if there is another object in this hand
    if (!IsHandFree(Hand))
    {
        return false;
    }
    // Return if object doesn't implement interface
    if (!Object->GetClass()->ImplementsInterface(UPickupObject::StaticClass()))
    {
        return false;
    }
    // Return if object can't be picked up now for some internal reasons
    if (!IPickupObject::Execute_IsPickable(Object))
    {
        return false;
    }

    // Detach from player's belt if the object was attached
    bool WasOnBelt = false;
    if (IsValid(PlayerBelt)) {
        if (PlayerBelt->IsGameplayActorAttached(Object)) {
            PlayerBelt->DetachGameplayActor(Object);
            WasOnBelt = true;
        }
    }

    // Disable physics simulation
    Object->DisableComponentsSimulatePhysics();

    // Update hand animation and attach object to the hand mesh
    FTransform RelativeOffset;
    SetHandPose(Hand, IPickupObject::Execute_GetHandPose(Object));
    Object->AttachToComponent(GetHandMesh(Hand), FAttachmentTransformRules::KeepWorldTransform);

    // Update references and flags, get desired transform relative to hand
    if (Hand == EControllerHand::Right)
    {
        RightHandObject = Object;
        // <---- ObjectOffsetRight is a Transform
        ObjectOffsetRight = IPickupObject::Execute_GetTransformRelativeToHand(Object, Hand);
        IsAttachingObjectRight = true;
    }
    else
    {
        LeftHandObject = Object;
        // <---- ObjectOffsetLeft is a Transform
        ObjectOffsetLeft = IPickupObject::Execute_GetTransformRelativeToHand(Object, Hand);
        IsAttachingObjectLeft = true;
    }

    // <----
    // Here you should use ObjectOffsetLeft/ObjectOffsetRight transforms in
    // Object->GetRootComponent()->SetRelativeLocationAndRotation()
    // I use soft interpolation, so I don't need an instant update.

    // Ignore collisions with this actor
    if (!WasOnBelt)
    {
        MovementIgnoringActors.Add(Object);
    }

    // Send event to notify object that it was picked up
    IPickupObject::Execute_OnPickedUp(Object, Hand);

    return true;
}

[/SPOILER]

And an example of how it works:
https://youtube.com/watch?v=x0y4Fcoj3Fg

thanks YuriNK Thats some really nice work and exactly what I want .
Im not a coder, like to do everything in Blueprints , but I will give this a try if there are no Blueprint solutions or may even try to pull it off with a snap to solution.
or continue to look in the Robo recall modkit blueprints

You can do the same things in blueprints. Just add this function to your PickUp interface and override it with custom relative transform in all actor blueprint implementing this interafce.

Hey @YuriNK, thanx for the script. At the and of the video you are touching (with pointing hand animation) physically to 3dwidget (probable in actor) menu panel, how did you do that man its great, i dont wanna use widgetinteraction because when i say show debug, debug shapes showing up with extra black duplicates and also when im using MotionController (R) Trigger for Press/Release Pointer key losting other grab/grip ability ! If you can give some idea it would be awesome, thank you for your time…

It’s not a Widget Component, it’s a custom menu actor with static mesh, because I want cool noise effect and bloom. But you can do the same with Widget Component and Widget Interaction Component. Just turn off debug draws in Interaction component settings and use small distance to plane instead of trigger press to send left mouse button event.

Hey @YuriNK i made exactly what you sad, i added index finger collider inside the hand mesh (inside the BP_Motion_Controller), (im not using widgetinteraction component anymore-i dont understand what you mean here:‘use small distance to plane’) only i cant connect widget to GetWorldTransform as a variable! Do i need to create some functions inside the button widget or what ? Thank you…

Hwew you need to get a plane of widget in world space, so make sure you’re connecting to GetWorldTransform node a reference to widget component, not widget object inside of this component.
By ‘use small distance to plane’ I mean that if you want to use touch event instead of trigger press, you can detect touching by measuring distance from index finger to display. If the distance is small (for examlpe, < 0.5), you can send LMB event to widget.

Hey @YuriNK
Here the details: Vr Interaction Tablet/Pad - Unreal Engine Forums
Sorry for disturbing this topic…