I am using version 4.25.3. with the VR template and converted to c ++.
I made a character with c++ to put as a basis for the motioncontrollerpawn.
In the code I added two subobjects VRroot and Camera.
Code:
// Sets default values AMotionController_ORPH::AMotionController_ORPH() { // Set this character to call Tick() every frame. You can turn this off to improve performance if you don’t need it. PrimaryActorTick.bCanEverTick = true; VRRoot = CreateDefaultSubobject<USceneComponent>(TEXT(“VRRoot”)); VRRoot->SetupAttachment(GetRootComponent()); Camera = CreateDefaultSubobject<UCameraComponent>(TEXT(“Camera”)); Camera->SetupAttachment(VRRoot); } // Called when the game starts or when spawned void AMotionController_ORPH::BeginPlay() { Super::BeginPlay(); } // Called every frame void AMotionController_ORPH::Tick(float DeltaTime) { Super::Tick(DeltaTime); FVector NewCameraOffset = Camera->GetComponentLocation() - GetActorLocation(); NewCameraOffset.Z = 0; AddActorWorldOffset(NewCameraOffset); VRRoot->AddWorldOffset(-NewCameraOffset); } // Called to bind functionality to input void AMotionController_ORPH::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); }
The position of the capsule and the camera are aligned and works fine.
Then I turned this character into a BP that I use as a parent class of the motion controller of the template, with blueprints I added a basic locomotion for use with the controls of the visor, everything works fine, the collision capsule is attached to the camera and the movement but I have a problem, when I press the grab button, and I bring my hand closer to some static mesh, it comes out propelled upwards without controlls. (N ot like the ironman or like a NASA spacecraft with its thrusters controlling the steering.)
[ATTACH=CONFIG]n1818515[/ATTACH]
Could someone help me?
Thanks in advance.