// .h
/** pawn owner /
UPROPERTY(Transient, ReplicatedUsing=OnRep_MyPawn)
class AShooterCharacter MyPawn;
/** set the weapon's owning pawn */
void SetOwningPawn(AShooterCharacter* AShooterCharacter);
/** [server] weapon was added to pawn's inventory */
virtual void OnEnterInventory(AShooterCharacter* NewOwner);
// .ccp
void AShooterWeapon::OnEnterInventory(AShooterCharacter* NewOwner)
{
SetOwningPawn(NewOwner);
}
void AShooterWeapon::SetOwningPawn(AShooterCharacter* NewOwner)
{
if (MyPawn != NewOwner)
{
Instigator = NewOwner;
MyPawn = NewOwner;
// net owner for RPC calls
SetOwner(NewOwner);
}
}
This is the example for the shooter game. Some how they never initialize the pawn which I need because I reference it in sub classes. MyPawn is never explicitly initialized and I have looked at every part.