Download

Picking up Objects with Vive beyond just AttachActorToComponent

So I’ve been working on creating a system for manipulating objects with one and two hands. Ideally you can pick up any physics object with at least one hand, some have two hands enabled.
The primary usecase is for throwing items, holding handguns, and holding rifles.

As far as I can tell there are three ways to do this: AttachActorToComponent, Physics Constraints, and Physics Handles.

AttachActorToComponent
Advantages: Easy to use, works well for single handed items.
Disadvantages: Too rigid, requires temporarily disabling physics, items clip through others, no dampening so long items shake from your hand tremors and tracking glitches.

Physics Constraints
Advantages: Very adjustable, has dampening, you can keep physics, items push off others passably well
Disadvantages: Too loose, items lag behind your hand, you have to attach to a static mesh and you can’t choose the location for it (difficult for two handed objects)

Physics Handle
Advantages: This seems to be its intended purpose. Has dampening, items push off others very well
Disadvantages: Very loose, lags behind hand, can’t set as child of other component so you have to manually set location every frame. Very little information about how they work (that I could find).

So far I haven’t been able to find a good solution. Is my understanding of this problem correct?
What are you guys doing to solve this?
Thanks for the help. Hopefully we can come up with and document a great solution for this.

I’ve been meaning to make a thread like this, so I’m glad you did. I would like to use a physics handle but I’m having issues getting it to work right. I don’t mind if it lags behind a bit but I just want it to act like AttachActorToComponent, it stays at a set point away from the vive controller and rotates along with it. I got some basic functionality but I guess I’m going to have to do a bunch of vector and rotation math in order to get it to work properly.

I couldn’t get the physics handle to work at all when I tried - I mean it was doing something, but never what I’d expect it to do. I’ve been considering looking into employing the actual physics engine to handle ‘grip’, which will be no small feat.

I made a grip plugin for the SteamVR template in here with custom MotionControllerComponents that supports better gripping mechanics. Someone was modifying it themselves for two handed grips and I don’t see why it would be that hard to achieve.

You are right, the physics constraints are lackluster because of the delay in movement (they also don’t receive render thread positional updates), the physics handle is just a managed physics constraint, it has all of the same issues, and the attachto has issues not just because of what you mentioned, but also because the engine throws out sweeping attached actors so you can’t use “EventHit” and they will pass through geometry.

The plugin originally added a sweep to all attached actors of a controller but now just has them move towards it and collects their components for the controllers late rendering thread positional updates. You could add tremor damping to it if you wanted to by modifying both the late and normal tick update positions but I honestly wouldn’t suggest it. In my opinion tremor is a necessary evil to correct tracking as things are performing as they would out of game (pick up a pen and hold it out without any tremor, I can’t).

Here is my original demo enviroment using it:

https://www.youtube.com/watch?v=0hCXV0-YDyQ

Here is the template I made it for:
https://forums.unrealengine.com/showthread.php?106609-Steam-VR-Template

Here is the plugin itself:
https://bitbucket.org/mordentral/ue4-vr-grippable-motion-controller-plugin

I couldn’t find an immediate solution that was better than this. I do have to update it for 4.12 though, due to overriding a private class within a class acting weird in UE4 I just re-wrote the entire motion controller component so I need to pass over changes in new versions (if there are any) manually at the moment.

It has multiple styles of gripping available based on how you use it (free grip, snap, snap within radius, no collision but still hit events). Covers about all of the bases as far as I am aware, I probably should have broke it out into its own thread at some point.

I’d rather not have to use something that ends up having to replace parts of the engine. I got somewhat close with my physics handle solution, so I guess I’ll keep banging away at that. For now, attaching works for my needs.

I have been experimenting with both the attach to component process and the physics handles and at the moment I am leaning towards physics handles for picking up and throwing things and attach to component for picking up and holding guns.
I have the gun part sort of figured out (just recreating a blueprint from the Epic youtube videos) but I haven’t implemented it yet. Here’s a quick little video showing my progress with the physics handles though. I still need to tweak the physics to get the mass/dampening and stuff to behave like a snowball… but I can pick things up and throw them now.
https://youtube.com/watch?v=bQv4A1vCenE

Oooooooo I like that physics behavior. I hope I can get mine to work in a similar fashion as far as feeling “good” to throw things. If not I may end up using your plugin. I have definitely learned a lot recently about blueprints and VR development from my project. Wild wild west out there right now.

I’ll try out your Grip plugin, I did use it as part of your template but I haven’t played with its settings yet.

Currently I am using AttachTo for Guns (1 and 2handed) and using physics actors for some thrown objects. I’ll post some videos later once I have it well polished

Below is the system I’m using at the moment. Very easy to set up. Took me about 3 minutes to migrate to my project and setup. You can pick up any object in the world that you can turn on the physics on. In the below video you see me add a basic cube turn on the physics then pick up in game. It’s not my pickup system so I would want to get permission from the owner before I talk about it but I am very excited about using it in my game because of how easy it is to setup.

https://youtube.com/watch?v=o6XTpG7bHVw

The video does not show what happens if you try to clip objects through the walls. Are they stopped?

They are stopped yes

All in BP? I don’t think that is actually possible while retaining the late positional updates. I could see how to do it while throwing late updates away, but not with keeping it.

Its not mine so I can’t say exactly how it works. All I can say is that all you have to do is add a child actor component to you controller, load up the BP and then set any mesh to physics and you can then pick it up.

Here’s my solution
https://github.com/mitchemmc/VRContentExamples/releases/tag/V1.2
It’s part of my VR Content Examples
You can see a video of it working here:
https://youtube.com/watch?v=6MWGr3iMdZ8

It’s all done in blueprints and has late updates :slight_smile:

And a nice one it is too, in fact all of your work is great (I really like your teleport setup).

But if you were referencing my post where I said you couldn’t BP it with late updates I was talking about blocking held item movements and event hits not being BP possible, typical pick up is pretty straight forward with AttachTo. The engine doesn’t movement sweep attached objects (for good reason, it doesn’t make sense most of the time), so you don’t get some of the more outlier pick up interactions (loading a mag into a gun and having it collide if in the incorrect location for example) unless you go Physics constraint and throw out late updates or sweep held objects manually.

Really it would be great if there was an option to sweep attached actors in the engine itself, would open up more utility and wouldn’t break the default usage. I could also lower how many plugins I update every patch.

If it requires the object to be simulating it probably uses a constraint/grab handle, so it would work perfectly for everything but late updates. That style isn’t a deal breaker, there are a lot of interaction schemes where late updates aren’t needed at all (specifically when you don’t show hands it isn’t as jarring).

Yeah I get you, when I was messing with this stuff a while ago I do remember something about sweeping child components but can’t remember if it was you could or couldn’t do it a certain way, so I guess I’ll just take your word for it.

The way mine works is by welding the physics objects to the motion controller component so I believe they should get the late updates this also means that any collision still works as it is just the physics system doing the hit detection.

Yeah you will get all physics collision on objects you are hitting, it also does retain late positional updates. It works fine for everything but offsetting the held object when it collides so that it won’t pass through things.

Honestly for 90% of cases that is what people would want anyway. They would just have to use a trace for impact detection since the OnHit node won’t trigger, there are some samples of melee combat doing that already on the forums (think Rama has a writeup).

Actually what’s cool about welding the physics body is it has all the collision.
As you can see here it’ll even collide with a static mesh
https://youtube.com/watch?v=zqJqNokWus4

Thats pretty cool, that makes everything but the onhit node functional just in BP as is (pretty much everything as I think On/End overlap should work). Welding bodies didn’t work for me but I was using thin objects with small collision, it probably was just passing through, I never tested with better objects.

Edit You are also running a scene root separate in it, that might be why it works better. I’ll let Proteus know, this should be good enough that he could drop the plugin for his simple template. OnHit isn’t a deal breaker and example templates really should be all Blueprint. I’d rather not encourage using a plugin if there are close equivalents attainable without them.

Hello, thank you so much for sharing this implementation. I’m wondering if the MotionController component is attached to the IK hands? I’m trying to use attach to to snap my MotionController pawn to my character’s hand socket, but the controller pawn will always drifted away from the hand after I move my controller. And I’d greatly appreciate it if anyone can please give me some hints.