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"

How to find Oculus Touch controller forward vector in C++

Hello

I am trying to make a teleport system where the user chooses their location with the touch controller. Kind of like the way roborecall does it but without needed to press any buttons to show teh destination. Still at the phase of getting it to work.

NOTE the system using the HMD but when I try to use the controller it will only put the marker right below my hand

In my character class I included #include "MotionControllerComponent.h" #include "XRMotionControllerBase.h"

Then in my constructor I have (the controllers show up and are tracking) LeftController = CreateDefaultSubobject(TEXT("LeftController")); LeftController->SetupAttachment(VRRoot); LeftController->MotionSource = FXRMotionControllerBase::LeftHandSourceId;

 RightController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("RightController"));
 RightController->SetupAttachment(VRRoot);
 RightController->MotionSource = FXRMotionControllerBase::RightHandSourceId;

Then to update the destination I have the following code

    FVector Start = LeftController->GetComponentLocation();
 FVector Look = LeftController->GetForwardVector();
 Look = Look.RotateAngleAxis(30, LeftController->GetRightVector());
 FVector End = Start + Look * MaxTelDistance;

 FHitResult HitResult;
 bool bHit = GetWorld()->LineTraceSingleByChannel(HitResult, Start, End, ECC_Visibility);

 FNavLocation NavLocation;
 bool bOnNaveMesh = GetWorld()->GetNavigationSystem()->ProjectPointToNavigation(HitResult.Location,    

NavLocation, TeleportPorjectionExtent);

 if (bOnNaveMesh && bHit)
 {
     DestinationMarker->SetWorldLocation(NavLocation.Location);
     DestinationMarker->SetVisibility(true);
 }
 else
 {
     DestinationMarker->SetVisibility(false);
 }


 Which should send the destination marker out MAXTELDISTANCE (which is set to 1000). It works when I use the HMD camera but teh Touch controllers seem not to have a forward vector. I looked at the UE VR sample and the roborecall mod kit but still can not figure this one out       
Product Version: UE 4.19
Tags:
more ▼

asked Apr 24 '18 at 11:16 PM in VR

avatar image

nrm21122
11 3 5

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

0 answers: sort voted first
Be the first one to answer this question
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