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"

VR Pawn Component Heirarchy Incorrectly Instantiating

Hello, I am just starting out with Unreal and with developing for VR and I am having some issues setting up the VR_Pawn in C++. One thing I wanted to do was create a component derived from UMotionControllerComponent for the hands so that I didn't have to replicate functionality for the left and right hand. The issue I am having is when I try to make a blueprints class based on the VR_Pawn that I have created. The component heirarchy that I expect is completely thrown off, for example, I would expect to see each HandComponent to have a static mesh and an arrow component, however the blueprint shows that one of the HandComponents is storing BOTH meshes and the other HandComponent is storing BOTH arrow components (or some other random combination of the components). Am I approaching this from the wrong angle? Is the issue that they have the same name? Thank you in advanced for your help! Here is the code:

Blueprints result

alt text

HandComponent.h

 UCLASS()
 class OVERSHOULDERS_API UHandComponent : public UMotionControllerComponent
 {
     GENERATED_BODY()
 
 public:
     //Set Default Values
     UHandComponent();
 
     UPROPERTY(VisibleAnywhere)
         class AInteractActor* IsBusy;
     UPROPERTY(VisibleAnywhere)
         class AInteractActor* Nearby;
     UPROPERTY(VisibleAnywhere)
         UStaticMeshComponent* Mesh;
     UPROPERTY(VisibleAnywhere)
         UArrowComponent* HoldLocation;
     
 };

UHandComponent.cpp

 UHandComponent::UHandComponent() {
     IsBusy = NULL;
     Nearby = NULL;
 
     // Create Mesh for Hand
     Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
     Mesh->AttachTo(this);
     Mesh->RegisterComponent();
 
     // Create Arrow Component as attach location for objects
     HoldLocation = CreateDefaultSubobject<UArrowComponent>(TEXT("Hold Location"));
     HoldLocation->AttachTo(this);
     HoldLocation->RegisterComponent();
 }

VR_Pawn.h

 UCLASS()
 class OVERSHOULDERS_API AVR_Pawn : public APawn
 {
     GENERATED_BODY()
 
 public:
     // Sets default values for this pawn's properties
     AVR_Pawn();
 
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
     
     // Called every frame
     virtual void Tick( float DeltaSeconds ) override;
 
     // Called to bind functionality to input
     virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
 
 
 
     UPROPERTY(VisibleAnywhere)
         USceneComponent* DefaultRoot;
 
     UPROPERTY(VisibleAnywhere)
         UCapsuleComponent* Body;
     UPROPERTY(VisibleAnywhere)
         USceneComponent* Container;
     UPROPERTY(VisibleAnywhere)
         UCameraComponent* HMD;
     UPROPERTY(VisibleAnywhere)
         class UHandComponent* Left;
     UPROPERTY(VisibleAnywhere)
         class UHandComponent* Right;
 
     UPROPERTY(VisibleAnywhere)
         class USteamVRChaperoneComponent* SteamVR;
     
 };

VR_Pawn.cpp constructor

 // Sets default values
 AVR_Pawn::AVR_Pawn()
 {
     // Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
     BaseEyeHeight = 0.0f;
 
     // Create Default Root Object
     DefaultRoot = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
     //DefaultRoot->SetRelativeLocation(FVector(0, 0, 0));
 
     // Create the Body of the player in the space
     Body = CreateDefaultSubobject<UCapsuleComponent>(TEXT("BODY"));
     //Body->SetRelativeLocation(FVector(0, 0, 0));
     Body->SetCapsuleHalfHeight(96);
     Body->SetCapsuleRadius(16);
 
     // Create a Scene Object Holder for Camera and Controllers
     Container = CreateDefaultSubobject<USceneComponent>(TEXT("Container"));
     //Container->SetRelativeLocation(FVector(0, 0, -110));
 
     // Create the Camera and subsequent HMD
     HMD = CreateDefaultSubobject<UCameraComponent>(TEXT("HMD"));
     HMD->SetupAttachment(Container);
 
     // Create the Hand Controllers
     Left = CreateDefaultSubobject<UHandComponent>(TEXT("Left"));
     Left->SetupAttachment(Container);
     Left->RegisterComponent();
     Left->Hand = EControllerHand::Left;
 
     Right = CreateDefaultSubobject<UHandComponent>(TEXT("Right"));
     Right->SetupAttachment(Container);
     Right->RegisterComponent();
     Right->Hand = EControllerHand::Right;
 
     // Create SteamVR Chaperone
     SteamVR = CreateDefaultSubobject<USteamVRChaperoneComponent>(TEXT("SteamVRChaperoneComponent"));
     AutoPossessPlayer = EAutoReceiveInput::Player0;
 }


Product Version: UE 4.14
Tags:
capture.jpg (46.7 kB)
more ▼

asked Jan 22 '17 at 05:56 PM in VR

avatar image

The_O_King
1

(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