For starter, I’m new to Unreal and c++.
I want my player to interacted with certain object like light switch or object to pick up. So I created a class AInteractableObj : public AActor
with a function void Activate()
.
In an other class UInteract : public USceneComponent
, I shoot a ray with SweepSingleByChannel()
to see if it Hit an interactable object. if it’s true I want to be able to call Activate()
.
Now here’s my problem, when I try:
FHitResult HitResult;
bool bHasHit = CanInteractDistance(HitResult);
if(bHasHit)
{
AInteractableObj InteractableObj;
InteractableObj = HitResult.GetActor();
InteractableObj.Activate();
}
it tells me that I cannot initiate an AInteractableObj with an AActor*, which is fair enought. But how should I do it?