x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Attach Character Collision Capsule to HMD (SteamVR)

I'm using an HTC Vive in SteamVR. I have managed to set up an empty character component with movement mapped to the motion controller thumbpads and a camera locked to the HMD, but I can't seem to get the collision capsule to follow the HMD since it is the blueprint root; it always stays in the center of the chaperone space. I've now rigged up a second collision capsule, as suggested here, and I am updating its position and half-height on each tick so that it stretches from the floor to the HMD location. This works well for interactions with physics objects (I can now push things around by walking into them), but my collision with the floor is still dictated by the original capsule in the center of my play space. This means that in order to walk off of a ledge, I have to be moving using the thumbstick; if I physically walk off the ledge I will hang in mid air. When walking up a ramp, my body capsule will just overlap the floor. I've attempted to disable collision on the root capsule, but this causes me to immediately fall through the floor... as far as I can tell this is happening because my body capsule is teleporting on each tick, and it's impossible to move a non-root component via sweep. Is there any way to attach the root capsule to the HMD in order to make interactions with the floor a bit more natural?

Product Version: UE 4.12
Tags:
more ▼

asked Aug 22 '16 at 03:28 AM in VR

avatar image

SlimeQ
332 10 21 38

avatar image Kilargo Oct 02 '16 at 01:10 AM

Any fix or potential update to this?

avatar image SlimeQ Oct 03 '16 at 11:01 PM

see my answer

avatar image sealfoss Mar 21 '17 at 06:08 PM

Is this still the best solution, as far as you're aware of?

avatar image SlimeQ Mar 21 '17 at 08:38 PM

i'd recommend using mordentral's VRExpansionPlugin https://bitbucket.org/mordentral/vrexpansionplugin

avatar image sealfoss Mar 22 '17 at 03:56 AM

Oh yeah, I've seen it. Great stuff. I'm just trying to roll my own over here though :)

avatar image SlimeQ Mar 22 '17 at 09:35 PM

i've basically just hacked it to pieces to fit my needs. good luck!

edit: it's worth noting that the plugin has received a ton of updates since october, it's really pretty good

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

5 answers: sort voted first

After doing this all myself and getting subpar results, I found mordentral's VRExpansionPlugin which does proper multiplayer enabled collision out of the box. More info here: https://forums.unrealengine.com/development-discussion/vr-ar-development/89050-vr-expansion-plugin

I honestly can't recommend this enough, saved me a ton of time and effort.

more ▼

answered Dec 13 '17 at 11:47 PM

avatar image

SlimeQ
332 10 21 38

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Assuming you have this setup where the camera follows your HMD (note the scene node parenting your HMD camera)

alt text

The simplest method I know to get what you're looking is to use something like this function in you character BP (open image in a new tab to see full resolution)

alt text

We sample the camera relative location, null out the Z axis and get the delta with its old position. We add that delta vector to the collision position and subtract the same delta from the camera offset. Finally we update the old camera position as "OldPosition" member variable. That's it.

Here's the bp pastebin: https://blueprintue.com/blueprint/u-me1t6x/

You'll should be able to walk off ledges and push things around as expected.

Edit: updated to fix rotation, this is done by rotating our DeltaPos by the collision rotation (should only be yaw) but only when added to the collision component, don't rotate the delta for the camera offset.

more ▼

answered May 04 '17 at 05:40 PM

avatar image

getnamo
726 36 15 42

avatar image Modeus Games Jul 15 '17 at 06:40 PM

When do you call the sync function? Currently I'm calling from EventTick and it seems like when I turn my head, the camera is moving in the opposite direction. Same setup as shown above with Camera parented by a Scene.

avatar image getnamo Jul 15 '17 at 06:45 PM

Event Tick should be sufficient. Depending on what you do, you may need to change the tick group, but by default it should just work on the regular tick interval.

avatar image Modeus Games Jul 15 '17 at 07:02 PM

I've unhidden the capsule so I can see it and it is following my camera, so that part works perfect. It's just that when I turn my head to the right, I move just slightly to the right and when I turn my head left then I move a little to the left. I'm not moving my player, just turning my head. I'll keep messing with it and update my original comment when/if I find a solution.

UPDATE/CORRECTION: When I move my head forward, like leaning forward, it is moving me backwards and vice versa.

I'll look into the tick group thing, never heard of that before now.

avatar image getnamo Jul 15 '17 at 07:07 PM

sounds like you may need to take into account the rotation of the camera in one of the location samples, e.g. camera xy by rotating that vector by the camera rotation before setting it.

avatar image thejturner Mar 02 '18 at 12:31 AM

getnamo I tried you function method and it seems to be working quite nicely.

One thing I can't figure out yet is how to offset the location of the camera and capsule. I would like the capsule to be offset so that it is centered roughly under my feet (as opposed to the HMD origin). Can you recommend a simple approach to doing this?

I've tried plugging in add vector nodes in various parts of the function but it's just pushes the capsule further away from the HMD on each tick. I tried adding a float to the relative location X of the camera but it just offsets it in world space, not relative to the position of the capsule.

avatar image getnamo Mar 02 '18 at 01:45 AM

Since the capsule is the root node in a character you cannot offset it with respect to actor origin, but you can move all the things attached to it. Consider adding a scene node where you parent everything else that you're interested in. If that doesn't work you may need to switch to a pawn which will allow you to customize the hierarchy fully.

avatar image swegononego Jul 21 '18 at 01:20 AM

Works great for position. I have orientation issues like Modeus Games. I'm turning the capsule with left thumbstick (cause I like games that let you do that otherwise I get tangled in the cable). position of the camera and capsule stay aligned however the more I turn the capsule, the more the orientation of the movement of the HMD and capsule misalign. I've tried many things but it always makes it worse.

I'm trying to add smooth locomotion and colision to the UVRF template. I'll post it there when I fix this.

avatar image getnamo Jan 18 '19 at 05:30 AM
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

The basic idea of the solution I came up with is to move the character on each tick towards the camera (or rather, a scene marker that is attached to the camera that is approximately where my neck is) and then update the VR origin scene component to keep the camera stationary. It's a bit tricky to set up, but works well.

Here is how I'm moving the character:

alt text

It is important to update the VR origin immediately after movement and before rendering, or you will get a lot of nauseating shaking. To do this I've bound a function to OnCharacterMovementUpdated like this:

Bind to OnCharacterMovementUpdated

UpdateSceneOffset looks like this:

UpdateSceneOffset

For thumbstick movement, I'm just moving the VR origin in the direction I want to move. I'm basically just adding a vector to the world position of the scene, then clamping it within ~30 cm (this is an arbitrary number but it needs to be greater than 0) of the location that would cause the camera to always be stuck to the capsule. This prevents you from walking through walls. This vector is calculated like this:

ideal scene location

And then moved like this, accounting for rotation because MoveComponentTo uses relative locations and physics sometimes causes the character to rotate and we don't want the camera to be affected:

thumbstick movement

I'm using MoveComponentTo because simply updating the location causes choppiness. Speed is controlled by a scalar applied to the thumbstick and (more critically) the delta on MoveComponentTo.

Update: Due to performance issues I moved this to C++. The relevant class can be found here.

Update2: Mordentral has a plugin available here that offers a much more robust solution to this problem.

more ▼

answered Oct 03 '16 at 11:01 PM

avatar image

SlimeQ
332 10 21 38

avatar image xd Purezy_ Oct 04 '16 at 02:11 PM

Hey SlimeQ,

Do you happen to have a sample character BP of this available anywhere to download so I could take a look at it? I'd really be interested in testing it out. Thanks!

avatar image SlimeQ Oct 05 '16 at 04:01 AM

No, it's unfortunately very tied up with the rest of my character and I don't really want to release that for reasons. Also I've been experiencing some performance issues so I've been switching it over to C++ for optimization. I guess I could just throw the class up on github when I'm done? Unless you really want it in blueprint for some reason

avatar image SlimeQ Oct 08 '16 at 07:39 AM

Sterilized and uploaded to github. All you'll need to do is create a blueprint derived from this class.

avatar image Sorrien Oct 07 '16 at 10:43 PM

I tried building out your approach as posted, and I got some pretty bad stuttering on the updates of the capsule. I ended up going back to updating my capsule, mesh, and root via the SetWorldTransform function. It's pretty smooth, and I haven't gotten any stuttering this way.

avatar image SlimeQ Oct 08 '16 at 07:40 AM

I got that too. I've since migrated all the functionality over to C++, you can find it here

avatar image Sorrien Oct 09 '16 at 10:42 PM

Did that fix the stuttering? It felt more like it had to do with the delay caused by running the update on character movement for the capsule

avatar image SlimeQ Oct 10 '16 at 01:31 AM

It fixed it on my machine. Theoretically there should be no delay as long as the update happens between movement and rendering within the acceptable framerate. You might also be interested in [this guy's plug in][1]. He accomplished the same goal by different means that allow for standard movement inputs to be used. It works very well [1]: https://forums.unrealengine.com/showthread.php?116782-VR-(OpenVR)-Expansion-Plugin

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

You can have an dummy character for take place and update collision with the world . The dummy is follow the camera vr then keep the contrains between them like fixed distance or vector. You move in real world -> camera do offset -> then dummy follow -> if the dummy has collid and stop -> check the fix distance or the fix vector -> make the camera revert offset. It work for me.

more ▼

answered Mar 09 '17 at 03:18 PM

avatar image

godbloc
31 1 1 3

avatar image Andrew Heartnet Dec 13 '17 at 11:24 PM

This works for me as well :D Thanks dude!!!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

The problem is that the camera is moving relative to the Actor (thus your actor doesn't move in World Space because the camera is inside the play space. Play space is effectively your Actor). Walking in the play space is moving the "Camera" and not the pawn / actor. That is how the Lock To HMD checkbox works, the engine is doing a very simple Query orientation and pose from an HMD if it is attached and that option is true. The collision capsule knows nothing of this. Sorry I don't have a better answer for you, this is actually making me wonder what happens when we go between Vive / Oculus.

One option is to always be moving the actor to keep you in the center of the play space but there are most likely a bunch of "gotchas" with that technique.

more ▼

answered Sep 01 '16 at 06:49 PM

avatar image

MrCorzell
16 1 2 7

avatar image SlimeQ Sep 05 '16 at 02:50 AM

I currently have a mechanism set up so that the character root is moved towards the camera component each tick (via the standard character movement input), and then the scene root is changed to center the playspace on a given static point. This works, but there is a subtle shaking that occurs because of the constant movement of the root object that makes me sick pretty fast. Also, having the static point makes thumbstick movement a bit awkward because it doesn't respond to physics quite right. I reckon if I were to capture the current playspace center at the beginning of a tick, add movement vectors, then adjust the scene root after physics are applied and before rendering occurs, it would fix both the shaking issue and the thumbstick movement. getting a hook for that second tick is proving tricky, however; I'm attempting to implement what is described here but I am a noob and it's not terribly straightforward

avatar image MosPetrov Apr 24 '18 at 07:50 AM

Hi @SlimeQ Did you manage to find any better solution to this problem ?

Regards!

avatar image SlimeQ Apr 25 '18 at 06:38 PM
avatar image MosPetrov Apr 26 '18 at 06:13 AM

Thanks for the answer.But is there any non- plugin solution for this, even not fully working?

avatar image SlimeQ Apr 26 '18 at 10:47 AM

If by non-plugin you mean built into the engine, then no.

But why don't you want to use a plugin? It's free and open source. And you are totally free to rip out the code for your own use. In my game I have pulled out and used the plugin code to create custom a custom VRCharacter class which extends the ShooterGameCharacter from shooter game sample. The most important piece of code is the VRMovementComponent, which basically does everything I mentioned above, very efficiently and multiplayer friendly.

I doubt you'll be able to find a better solution anywhere else right now. Cannot recommend it enough.

avatar image MosPetrov Apr 26 '18 at 10:54 AM

The answer is because i am not C++ familiar.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question