I modified the Character.h and Character.cpp.
Character.cpp
#pragma once
//#include "Player.h"
#include "Controls.h"
#include "LogicComponent.h"
#include "Player.h"
using namespace Urho3D;
const int CTRL_FORWARD = 1;
const int CTRL_BACK = 2;
const int CTRL_LEFT = 4;
const int CTRL_RIGHT = 8;
const int CTRL_JUMP = 16;
const float MOVE_FORCE = 0.8f;
const float INAIR_MOVE_FORCE = 0.02f;
const float BRAKE_FORCE = 0.2f;
const float JUMP_FORCE = 1.0f;
const float YAW_SENSITIVITY = 0.1f;
const float INAIR_THRESHOLD_TIME = 0.1f;
/// Character component, responsible for physical movement according to controls, as well as animation.
class Character : public LogicComponent
{
OBJECT(Character)
public:
/// Construct.
Character(Context* context);
/// Register object factory and attributes.
static void RegisterObject(Context* context);
/// Handle startup. Called by LogicComponent base class.
virtual void Start();
/// Handle physics world update. Called by LogicComponent base class.
virtual void FixedUpdate(float timeStep);
/// Movement controls. Assigned by the main program each frame.
Controls controls_;
private:
/// Handle physics collision event.
void HandleNodeCollision(StringHash eventType, VariantMap& eventData);
/// Grounded flag for movement.
bool onGround_;
/// Jump flag.
bool okToJump_;
/// In air timer. Due to possible physics inaccuracy, character can be off ground for max. 1/10 second and still be allowed to move.
float inAirTimer_;
Player CharacterPlayer;
};
Character.cpp
using namespace std;
Character::Character(Context* context) :
LogicComponent(context),
onGround_(false),
okToJump_(true),
inAirTimer_(0.0f),
CharacterPlayer()
{
// Only the physics update event is needed: unsubscribe from the rest for optimization
SetUpdateEventMask(USE_FIXEDUPDATE);
}[/code]
This is the error I get when I compile it
[code]||=== Urho3D, all ===|
CMakeFiles/ExistenceClient.dir/Character.cpp.o||In function `Character::Character(Urho3D::Context*)':|
Character.cpp|| undefined reference to `Player::Player()'|
Character.cpp|| undefined reference to `Player::~Player()'|
CMakeFiles/ExistenceClient.dir/Character.cpp.o||In function `Character::~Character()':|
Character.cpp:(.text._ZN9CharacterD2Ev[_ZN9CharacterD5Ev]+0x17)||undefined reference to `Player::~Player()'|
CMakeFiles/ExistenceClient.dir/Character.cpp.o||In function `Character::~Character()':|
Character.cpp:(.text._ZN9CharacterD0Ev[_ZN9CharacterD5Ev]+0x17)||undefined reference to `Player::~Player()'|
CMakeFiles/ExistenceClient.dir/Character.cpp.o||In function `Urho3D::ObjectFactoryImpl<Character>::CreateObject()':|
::CreateObject()]+0x71)||undefined reference to `Player::Player()'|
::CreateObject()]+0xc4)||undefined reference to `Player::~Player()'|
||=== Build finished: 6 errors, 4 warnings ===|
So I’m not sure whats wrong. I was thinking of the Chracter object to use a Player class. So I don’t have to create major overhead for the GUI part.
Vivienne