Book Image

CryEngine Game Development Blueprints

Book Image

CryEngine Game Development Blueprints

Overview of this book

Table of Contents (22 chapters)
CRYENGINE Game Development Blueprints
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Making a camera follow the player


At this point, I advise you to test our game in the editor. You can do this by right-clicking the solution in Visual Studio and clicking on Build. Once our game is compiled, you can launch the CRYENGINE editor as usual, and it will automatically load our game. It's wonderful. So far, we have a completely playable character, but what happens when our player moves out of the camera's view? As you can see, we need a way for the player to move around but always stay in view. We can easily accomplish this by creating a following camera. The steps are as follows:

  1. The CPlayer class has camera code that we will not be using, so we need to remove such code. To do this, modify the PostInit() method in the CPlayer class so that all the camera-related code is removed. It should look like this:

    void CPlayer::PostInit( IGameObject * pGameObject )
    {
      //Allow This Instance To Be Updated Every Frame.
      pGameObject->EnableUpdateSlot( this, 0 );
    
      //Allow This Instance...