VRTemplate: VRPawn Line Trace from grabbed pistol is off when using Teleport

Hello everyone. I am observing some weird behaviour in the VRTemplate which I cannot explain, maybe somebody can help me.

The setup is pretty easy:

  1. Use Standard VR Template
  2. Try to start a line trace from the Muzzle Location of the Pistol Blueprint like in the image:
  3. Activate Draw Debug Type “For Duration” to constantly show the lines of the trace
  4. Observe: The moment you use the built-in Teleport from the VRPawn the Line Trace is totally off and is pointing in weird directions without any pattern to it. I really have no idea why.

Seems like them somehow the transformation of the Teleport offsets the pistol somehow, but the gun and all its children (eg. the Muzzle Location) are parented to the grabbing hand, so this should not happen.

Can anybody help me with this? It is really important and I am completely lost :frowning:

You can see this behaviour in images below, where for debug purposes I attachted a laser pointer to the muzzle location to show the forward vector, and in comparison the current line traces which are totally off from this true forward direction:




I was standing still for the above pictures so the line trace debug lines are actually off from the right direction. I do not see any actual pattern on the line trace, sometimes it is off a lot, sometimes nearly right

Thank you very much in advance for your help!

Hey @Maderschaden!

Is there any possible way you could get the behavior on video? The pictures are great and all but it’s really hard to tell what direction you’re turning, etc. :frowning:

1 Like

Yes sure Mind-Brain no problem! Here you go.
Do not worry about the block, that is just for a project of mine and is spawned at the end of the line trace. But because the line trace is off, so is the block at the end ^^

The behaviour is sooo weird and I have no idea why this is happening. I changed nothing about the VRTemplate excpet for the map a little bit as you can see.:confused:

HMMMM.

So troubleshooting is the name of the game here, for sure.

First let’s increase your hit distance to 100,000 and tear down that wall. We’re looking for a convergent point.

Also, I’d do a print string after GetForward off of the MuzzleLocation.

If that doesn’t clear anything up, let us know your results and we’ll regroup! :slight_smile:

So I printed the forward vector and that one is always right, even when the line trace itself is not, so this is not the problem.
But when I increased the hit distance to 100 000 it finally worked. I don’t understand why? Does anybody have an idea?

I actually need a smaller hit distance in the end, because I want to be able to select an arbitrary point in the air too (without a hit).

What is happening here? :thinking:

That IS wonky.

Have you changed it back to see if the problem just… fixed itself?

I really don’t know why it would be doing this. It seems like a VR issue, possibly. Are you testing it with the VR set?

1 Like

I was finally able to fix my problem and it was fairly trivial after I understood what I did wrong.
For anyone who has a similar problem sometimes in the future:

After multiplying my direction (forward vector) by a float I forgot to add the starting location (GetWorldLocation) to it.
So GetForwardVector * Float only ever gives me a direction and the reason why this worked when multiplying it with a very big number (100,000) was because after the direction got big enough it converged with the intended direction.

As you can see in my fixed solution, I can now use a much smaller Float (1000) to perform the linetrace because the “direction” (GetForwardVector) now has the starting location added to it.

1 Like