I have a scene component which is created in the constructor of an actor which is spawned by another actor. And the scene component creates a sphere component and attach to it in its constructor. (sorry it is a bit complex, but I did so because I wanted to separate them by role. I put more details below.) When I change the sphere radius in an instance blueprint of an actor(the one who creates the scene component), The change looks reflected in Viewport, but if I compile it, the change would be gone in Viewport although the value remains in Details view. In the game the change would be also ignored.
More defails of my project:
I am trying to make Pawn and controllers for VR with C++. I have Pawn and Hand(Actor), and Pawn spawns hands on BeginPlay and attach them to itself. Also, I have a grabber component(SceneComponent) which handles hand’s grab/release. In its constructor the component creates sphere component for overlapping check. A grabber component is created by each hand component! in the constructor and attached to it. I make Blueprints for each actors&components and use it.
Pawn spawning hands
void AMyVRPawn::BeginPlay()
{
Super::BeginPlay();
// spawn left HandController
if (HandControllerLeftClass)
{
FActorSpawnParameters HandSpawnParamsLeft;
HandSpawnParamsLeft.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
HandSpawnParamsLeft.Owner = this;
HandSpawnParamsLeft.Name = FName(TEXT("HandControllerLeft"));
HandControllerLeft = GetWorld()->SpawnActor<AHandController>(HandControllerLeftClass, FVector::ZeroVector, FRotator::ZeroRotator, HandSpawnParamsLeft);
FAttachmentTransformRules AttachRulesLeft(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::KeepWorld, false);
HandControllerLeft->AttachToComponent(VROriginComp, AttachRulesLeft);
HandControllerLeft->SetControllerHand(EControllerHand::Left);
}
}
Hand
AHandController::AHandController()
{
MotionControllerComp = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("MotionControllerComp"));
RootComponent = MotionControllerComp;
GrabberComp = CreateDefaultSubobject<UVRGrabberComponent>(TEXT("GrabberComp"));
GrabberComp->SetupAttachment(MotionControllerComp);
}
Grabber Component
UVRGrabberComponent::UVRGrabberComponent()
{
SphereComp = CreateDefaultSubobject<USphereComponent>(TEXT("SphereComp"));
SphereComp->SetupAttachment(this);
}
before change: Sphere Radius=32(default)
before compile: Sphere Radius=8.919662
after compile: Sphere Radius=8.919662
Changing other value such as Transform and Visible doesn’t reflect either.
Changing other component’s value like grabber’s transform does, though.
I can change the variable in C++ like:
SphereComp = CreateDefaultSubobject<USphereComponent>(TEXT("SphereComp"));
SphereComp->SetupAttachment(this);
SphereComp->SetSphereRadius(9.2f, true);
And the change would be reflected. But if I try to change in Blueprint, I cannot see the change in Viewport even before compile, anymore, and the if I compile&save, it gives me “can’t save … is linked to private object(s) in an external package” and I cannot save it. Making Grabber component EditAnywhere from VisibleAnywhere fixed the cannot-save issue. (Now other variables like the sphere component are EditAnywhere too.) But the change in blueprint is still ignored.
I am not sure at all if these behaviour is a bug or not.
I made this project using Oculus version of UE4.25(latest) with VS2019, and also migrated it to normal UE 4.25.3. Neither worked.