sorry for line 4 on 2nd code block:
FString start = Grabber->GetComponentLocation().ToString(); <---crashed on this line.
"Grabber" is just a TYPO on the post, doesn’t matter to the topic.
should be SceneComp → GetComponentLocation() though.
sorry for line 4 on 2nd code block:
FString start = Grabber->GetComponentLocation().ToString(); <---crashed on this line.
"Grabber" is just a TYPO on the post, doesn’t matter to the topic.
should be SceneComp → GetComponentLocation() though.
trying attach a USceneComponent to my UCameraComponent by codes below:
//create components
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
SceneComp = CreateDefaultSubobject<UGrabber>(TEXT("SceneComp"));
//attach Camera to current root
Camera->SetupAttachment(GetRootComponent());
//attah my SceneComp to Camera making it a hierarchy.
SceneComp->AttachToComponent(Camera,FAttachmentTransformRules::SnapToTargetIncludingScale);
the result visually looks great in editor:
Root
----Camera
--------SceneComp
but when i try for getting world location of my SceneComp using GetComponentLocation(),
whole editor was crashed:
void AFirstPersonCharacter::BeginPlay()
{
Super::BeginPlay();
FString start = Grabber->GetComponentLocation().ToString(); <---crashed on this line.
UE_LOG(LogTemp,Warning,TEXT("SceneComp is at: %s"),*start);
}
it seems like the way of attaching USceneComponent to another component was mistaken.
anyone could help?
FString start = SceneComp->GetComponentLocation().ToString();
Hey EvilCleric! you saved my life numberless times!
but my post here is sorta a mess.
i updated it with more coverd details on reddit,
attach a component which inherited from USceneComponent to another Component
could you have a look when you at convenience?
thank you!
btw, do you know is it possible to edit/delete posted post in UE4 answerhub?
Try protecting your pointer:
if (Grabber)
{
FString start = Grabber->GetComponentLocation().ToString();
UE_LOG(LogTemp,Warning,TEXT("SceneComp is at: %s"),*start);
}
else
{
UE_LOG(LogTemp,Error,TEXT("GRABBER COMP INVALID"));
}
Also, what is the UGrabber component?
Also, the crash log would really help.