Hey guys,
Bit of a strange one. Whenever the 1 line function below is called, the editor crashes. OpenAngle is set to 90.f and Owner is set in BeginPlay with GetFirstPlayerController(). Any ideas?
void UOpenDoor::OpenDoor()
{
Owner->SetActorRotation(FRotator(0.0f, OpenAngle, 0.0f));
}
MatzeOGH
(MatzeOGH)
July 8, 2017, 1:58pm
2
if your game crashes your owner ptr is not valid.
To be sure try this:
if(Owner)
{
Owner->SetActorRotation(FRotator(0.0f, OpenAngle, 0.0f));
}
Thanks for the quick reply! That’s stopped the crashing but interestingly that means that
AActor* Owner = GetOwner();
in BeginPlay() doesn’t set Owner. Is there a circumstance where GetOwner() doesn’t work?
ty
MatzeOGH
(MatzeOGH)
July 8, 2017, 2:16pm
4
That’s the case whenever an uobject isn’t owned by anything. You have to set the owner manually. Actor components do that for you.
it is an actor component, oh no!
MatzeOGH
(MatzeOGH)
July 8, 2017, 3:50pm
6
Are you creating the component in the actors constructor?
Thickovit
(Thickovit)
July 10, 2017, 8:52am
7
ah, there it is. both there and the header file. Such a noob!
Thank you
MatzeOGH
(MatzeOGH)
July 10, 2017, 10:54am
8
Can you accept the answer by any chance, Thanks