I’ve already tryed UE 4.22 and 23, but still got the same issue…
I’m trying to build a VR Oculus Quest C++ experience, and no, I don’t want to use blueprints for a while in this project. So no I wont try to code it via blueprint…
The problem is, all I want to do is make the hands open and close with a Bluperintanim (which I took from the VRPreview given by Unreal) but if I try to use the ConstructorHelpers like this:
static ConstructorHelpers::FObjectFinder<UAnimBlueprint>HandAnim(TEXT("AnimBlueprint'/Game/VirtualReality/Mannequin/Animations/HandAnimation.HandAnimation'"));
if (!HandAnim.Object)
{
UE_LOG(LogTemp, Warning, TEXT("HandAnim CONSTRUCTOR error..."));
return;
}
Or if I try to call it like this:
FString FilePath("/Game/VirtualReality/Mannequin/Animations/Hand_Animation.Hand_Animation");
FStringAssetReference AssetReference(FilePath); //FSoftObjectPath
TAssetPtr<UAnimBlueprint> AnimationAsset(AssetReference); //TSoftObjectPtr
UAnimBlueprint* AnimationBP = AnimationAsset.LoadSynchronous();
bool isValid = AnimationAsset.IsValid();
bool isNull = AnimationAsset.IsNull();
bool isPending = AnimationAsset.IsPending();
In both cases I can happily play the game with ZERO log errors and not even a bug in the Oculus Rift and in the Unreal preview. But every time I build this little guy in Oculus Quest my happyness goes away…
In the first code (ConstructorHelpers) when I build to Quest then he just goes all in black screen and don’t even play nothing.
in the second one (TAssetPtr) I can play it, but when I press the button to close the hands… guess what… nothing happens, not even crash… so please anyone HELP for GOD SAKE!
Like I said, everything is working fine everywhere but in Oculus Quest… so I’ve already tryed some stuff around the web.
I was wondering if maybe there is a way to set via the VRHand blueprint instead of copying it’s path inside the code. But the ways I tryed this doesn’t work… but maybe I was doing it wrong… I just don’t know what to do anymore…
Here is the mains code of the problem:
VRHands.cpp
#include "VRHands.h"
#include "MotionControllerComponent.h"
#include "Animation/AnimBlueprint.h"
AVRHands::AVRHands()
{
PrimaryActorTick.bCanEverTick = true;
MotionController = CreateDefaultSubobject<UMotionControllerComponent>(FName("MotionController"));
MotionController->SetRelativeLocationAndRotation(FVector::ZeroVector, FQuat::Identity);
MotionController->SetRelativeScale3D(FVector::OneVector);
SetRootComponent(MotionController);
static ConstructorHelpers::FObjectFinder<USkeletalMesh>MeshObject(TEXT("SkeletalMesh'/Game/VirtualReality/Mannequin/Character/Mesh/MannequinHand_Right.MannequinHand_Right'"));
if (!MeshObject.Object)
{
UE_LOG(LogTemp, Warning, TEXT("[ERROR] Mesh could not be created..."));
return;
}
SkeletalHandMesh = CreateDefaultSubobject<USkeletalMeshComponent>(FName("HandMesh"));
SkeletalHandMesh->SetSkeletalMesh(MeshObject.Object);
SkeletalHandMesh->SetupAttachment(MotionController);
SkeletalHandMesh->SetMobility(EComponentMobility::Movable);
SkeletalHandMesh->SetAutoActivate(true);
SkeletalHandMesh->SetVisibility(true);
SkeletalHandMesh->SetHiddenInGame(false);
SkeletalHandMesh->SetAnimationMode(EAnimationMode::AnimationBlueprint);
SetHandAnimation();
}
void AVRHands::BeginPlay()
{
Super::BeginPlay();
CacheHandAnimInstances();
}
void AVRHands::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AVRHands::SetHand(FName HandType)
{
MotionController->MotionSource = HandType;
FQuat HandRotation = FQuat::Identity;
FVector HandScale3D = FVector::OneVector;
if (HandType == FXRMotionControllerBase::LeftHandSourceId)
{
HandRotation = FQuat(FVector(1, 0, 0), FMath::DegreesToRadians(90));
HandScale3D = FVector(1, -1, 1);
}
else
{
HandRotation = FQuat(FVector(1, 0, 0), FMath::DegreesToRadians(270));
}
SkeletalHandMesh->SetRelativeLocationAndRotation(FVector::ZeroVector, FQuat::Identity);
SkeletalHandMesh->SetRelativeScale3D(HandScale3D);
}
void AVRHands::SetHandAnimation()
{
FString FilePath("/Game/VirtualReality/Mannequin/Animations/Hand_Animation.Hand_Animation");
FStringAssetReference AssetReference(FilePath); //FSoftObjectPath
TAssetPtr<UAnimBlueprint> AnimationAsset(AssetReference); //TSoftObjectPtr
UAnimBlueprint* AnimationBP = AnimationAsset.LoadSynchronous();
bool isValid = AnimationAsset.IsValid();
bool isNull = AnimationAsset.IsNull();
bool isPending = AnimationAsset.IsPending();
if (AnimationBP)
{
UAnimBlueprintGeneratedClass* HandGenerated = AnimationBP->GetAnimBlueprintGeneratedClass();
SkeletalHandMesh->SetAnimClass(HandGenerated);
SkeletalHandMesh->SetAnimInstanceClass(HandGenerated);
SkeletalHandMesh->AnimClass = HandGenerated;
}
else
UE_LOG(LogTemp, Warning, TEXT("[ERROR] AnimationBP is null..."));
}
void AVRHands::CacheHandAnimInstances()
{
HandAnimBP = Cast<UHandAnim>(SkeletalHandMesh->GetAnimInstance());
if (HandAnimBP)
UE_LOG(LogTemp, Warning, TEXT("HandAnimBP is casting..."));
if (!SkeletalHandMesh->GetAnimInstance())
UE_LOG(LogTemp, Warning, TEXT("[ERROR] HandAnimBP is not casting..."));
}
void AVRHands::Pressed()
{
if (HandAnimBP)
{
HandAnimBP->SetGripValue(1.0f);
}
}
void AVRHands::Released()
{
if (HandAnimBP)
{
HandAnimBP->SetGripValue(0.0f);
}
}
Maybe it is a bug in Oculus, android or even Unreal… but who knows!?
Thank you all for the atention!