Download

I need get variable from child class

i have a class called “Estructura”, where exist functions “deleteEstructures” “copyEstructures” “selectThis” “undo” “redo”,etc and one variable called PIVOT, “Estructura” has a parent class **AActor. **

now, i have a Blueprint Class,this Blueprint has a parent class “Estructura”. (therefore it is also an AActor).

i create a instance from this Blueprint Class (a new Actor in my world), this new actor has a Estructura parent class and the **Pivot **variable

i have a “LineTraceSingleByChannel” for select this structure with my mouse. and i need get the value of **PIVOT **variable from this structure selected, Hit.GetActor() but i cant, because i see only variables of AActor class and not variables AEstructura class


if (GetWorld()->LineTraceSingleByChannel(OutHit, camaraPosicion, (mousePositionWorldDireccion * 4000) + camaraPosicion, ECC_WorldStatic, CollisionParams))
    {
        if (construction) {

            FActorSpawnParameters SpawnParams;

            previoActual->SetActorLocation(OutHit.ImpactPoint);
            if (OutHit.Actor->ActorHasTag(TEXT("estructura"))) {

**                  pivotValue = OutHit.GetActor()->"GET_VARIABLE_FROM_CHILD_CLASS"**

**               I NEED GET "PIVOT" VARIABLE, FROM "AESTRUCTURA" CLASS, BUT NOT ONLY VARIABLES AACTOR CLASS, i need get hit actor as Estructura class.**
            }

            previoActual->SetActorRotation(FRotator(90, 0, 0) + UKismetMathLibrary::FindLookAtRotation(previoActual->GetActorLocation(), previoActual->GetActorLocation() - OutHit.ImpactNormal));


        }
    }

sorry for my bad english, i speak spanish.

greetings! and thanks

Try implementing a interface to the Object, and then create a dedicated function which executes when certain interface is detected in the object. You can do that on HitTesting.

Just cast the hit result to your “Estructura”. This way you can access all exposed properties.