#include "KPlayerController.h" #include "KInput.h" namespace KapitanGame { void KPlayerController::SetupInputBindings(KInput& input) { input.BindAxis("MoveX", shared_from_this(), &KPlayerController::MoveXAxis, Player); input.BindAction("Jump", InputState::Pressed, shared_from_this(), &KPlayerController::StartJump, Player); input.BindAction("Jump", InputState::Released, shared_from_this(), &KPlayerController::StopJump, Player); } void KPlayerController::MoveXAxis(const float axis) { Input.X += axis; } void KPlayerController::StartJump() { InputStartJump = true; } void KPlayerController::StopJump() { InputStopJump = true; } void KPlayerController::Update(float deltaTime) { Input.Normalize(); if (Pawn != nullptr) { Pawn->AddXMovementInput(Input.X); if (InputStartJump) Pawn->StartJump(); if (InputStopJump) Pawn->StopJump(); } Input *= 0; InputStartJump = false; InputStopJump = false; } void KPlayerController::Possess(KPawn* pawn) { Pawn = pawn; } void KPlayerController::UnPossess() { Pawn = nullptr; } const KPlayer& KPlayerController::GetPlayer() const { return Player; } }