Download

Casting to my character help

Trying to relearn the basics after having a year break from coding.

I am trying to get a reference for my character class so i can access the FirstPersonCamera from my WeaponBase class.
I am getting unexpected errors which i cannot remember how to fix them.



// Character.h

class AWeaponBase* WeaponBase;




// Character.cpp

#include "WeaponBase.h"

void AShooterCharacter::BeginPlay()
{
    // Call the base class  
    Super::BeginPlay();

    WeaponBase = GetWorld()->SpawnActor<AWeaponBase>();
    WeaponBase->ShooterCharacter = this;
}




// WeaponBase.h

class AShooterCharacter* ShooterCharacter;




// WeaponInstant.cpp

FVector Start = ShooterCharacter->GetFirstPersonCameraComponent.SetActorLocation();
FVector ForwardVector = ShooterCharacter->GetFirstPersonCameraComponent.GetForwardVector();


As you can see im trying to set my ShooterCharacter reference by spawning the Weaponbase and accessing it that way.
In the last snippet of code were i am trying to get the Camera the errors occur in the ShooterCharacter variable, as displayed in the picture.

You need to include your character class at the top of your WeaponInstant.cpp



#include "ShooterCharacter.h"


“Pointer to incomplete class” always means the compiler doesn’t know what that class is, normally because you’re missing an include.