All,
I’m stumped and hopefully a kind soul can tell me what I am missing.
I am seeing an Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffffffffffff on this line of code:
for (int Index = 0; Index < Elements.Num(); Index++)
{
if (IsValid(Elements[Index].SupportComp))
{
FName BoneName = Elements[Index].LastHit.BoneName;
// this next line crashes
FTransform SupportCompCurrentTransform = Elements[Index].SupportComp->GetSocketTransform(BoneName);
Elements is an array of USTRUCT. This USTRUCT is initialized with:
SupportComp gets populated in a different part of the code like this:
UPrimitiveComponent* SupportComp = Hit.GetComponent();
if (IsValid(SupportComp))
{
Elements[Index].SupportComp = SupportComp;
Where Hit is a HitResult.
This is a random crash which might take 5-10 minutes of gameplay before appearing. There are around 200 actors which run this code on tick, inside of a Custom Anim Node.
Given that I’m checking for Elements[Index].SupportComp's validity, why do you think I’m having an error on Elements[Index].SupportComp->GetSocketTransform(BoneName)?
Thank you Ramon for taking some time for this, appreciated Could you tell me why this might be needed? I’m gonna try it out asap but I’m curious to understand why this might make a difference.
EDIT: a little googling brought me to this, so it’s probably why you’re telling me to insert that as well:
However they refer to pointers for AActor or UActorComponent and I might have missed the UPrimitiveComponent references.
Any property that is not marked with UPROPERTY() can be garbage collected at any time. When you add UPROPERTY() to your property, it is associated with the object (that holds the property), and if that object is still alive, the property survives the GC