I am trying to get access to my player pawn from an actor. I am not sure what to do. Please help. thanks.
You have to cast from the Actor to your pawn class.
void YourClass::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if ((OtherActor != this))
{
AYourPawnClass* tempPawn = Cast<AYourPawnClass>(OtherActor);
if(tempPawn)
{
tempPawn->VariableYouWantToAccess = 10;
}
}
}
My apologies if I’ve misunderstood the question. if you’re interested in an actor like a projectile that has been called to be spawn by the owning pawn. GetInstigator may be a solution or custom collision channels
1 Like
Yup yup, I figured it out earlier but forgot to comment. I used the following lines of code`enter code here
for (FConstPawnIterator Iterator = GetWorld()->GetPawnIterator(); Iterator; ++Iterator)
{
if (Iterator->Get()->GetName() == "VR_PlayerChaperone_0")
{
auto i = Cast<AVR_PlayerChaperone>(Iterator->Get());
if (i->arrow)
i->arrow->current_arrow_state = AProjectileArrow::AIM;
}
}