Why does Player.h create two instances of itself in its public definition?

#1
In player.h, it opens the class CPlayer and starts with these lines
public:
CPlayer();
virtual ~CPlayer();

My first question is what exactly is virtual and what is the ~ mean next to the CPlayer (For some reason ~ looks like a dash on this forum, it is a tilde(squiggly line))? Secondly, What is the purpose of creating a instance of itself inside the header file? Later on in the Player.Cpp file it does this

CPlayer::CPlayer()
: m_pInput(nullptr)
, m_pMovement(nullptr)
, m_pView(nullptr)
{
}

CPlayer::~CPlayer()
{
gEnv->pGameFramework->GetIActorSystem()->RemoveActor(GetEntityId());
}

What is going on in those lines? To me it looks like it is defining the CPlayer() from player.h to have null values for input movement and view. Then it takes the ~CPlayer from player.h and removes the actor? Please explain. Thanks

Re: Why does Player.h create two instances of itself in its public definition?

#2
https://stackoverflow.com/questions/461 ... estructors


CPlayer is Game Object Extensions, which must attach to gameobject. when all extention attach success, call Init(GameObject ) on each extensions, the parameter gameobject represent gameobject which is essence an entity compliant to IGameObject Extension. it is safer to obtain other attach extension in init function and after init.

Who is online

Users browsing this forum: No registered users and 2 guests

cron