def going to need a full blown player controller, so..

move input to the player controller, need to fwd  to character
This commit is contained in:
Dexter Haslem 2017-03-28 21:15:40 -06:00
parent 6f2912df46
commit 9ec0b52420
6 changed files with 100 additions and 63 deletions

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ce5ed9956ea013a4f546ca678899221af1b7e06b36a9435ea0e21bda7d02ccee
oid sha256:55ac1855ecb0ea889df765558084125c7cc4ab03670ae84babaa60df3651c6fb
size 635306

View file

@ -2,6 +2,7 @@
#include "FF.h"
#include "FFGameModeBase.h"
#include "Private/FFPlayerController.h"
AFFGameModeBase::AFFGameModeBase() : Super()
{
@ -15,4 +16,7 @@ AFFGameModeBase::AFFGameModeBase() : Super()
DefaultPawnClass = ADefaultPawn::StaticClass();
UE_LOG(LogTemp, Error, TEXT("Failed to find FFCharacterBase, check data blueprint exists"));
}
PlayerControllerClass = AFFPlayerController::StaticClass();
}

View file

@ -15,8 +15,6 @@ AFFCharacter::AFFCharacter()
CameraComponent->RelativeLocation = FVector(-39.56f, 1.75f, 64.f);
CameraComponent->SetupAttachment(GetCapsuleComponent());
CameraComponent->bUsePawnControlRotation = true;
MouseSensitivityRate = 150.0f;
}
// Called when the game starts or when spawned
@ -31,50 +29,4 @@ void AFFCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AFFCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
// set up gameplay key bindings
// super checks
Super::SetupPlayerInputComponent(PlayerInputComponent);
// TODO: the base ACharacter jump handling kinda stinks
//PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::InputJump);
//PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::InputStopJumping);
PlayerInputComponent->BindAxis("Forward", this, &AFFCharacter::InputForward);
PlayerInputComponent->BindAxis("Strafe", this, &AFFCharacter::InputStrafe);
PlayerInputComponent->BindAxis("LookX", this, &AFFCharacter::InputLookX);
PlayerInputComponent->BindAxis("LookY", this, &AFFCharacter::InputLookY);
}
void AFFCharacter::InputForward(float Value)
{
if (Value != 0.0f)
{
// add movement in that direction
AddMovementInput(GetActorForwardVector(), Value);
}
}
void AFFCharacter::InputStrafe(float Value)
{
if (Value != 0.0f)
{
// add movement in that direction
AddMovementInput(GetActorRightVector(), Value);
}
}
void AFFCharacter::InputLookX(float Rate)
{
// calculate delta for this frame from the rate information
AddControllerYawInput(Rate * MouseSensitivityRate * GetWorld()->GetDeltaSeconds());
}
void AFFCharacter::InputLookY(float Rate)
{
// calculate delta for this frame from the rate information
AddControllerPitchInput(Rate * MouseSensitivityRate * GetWorld()->GetDeltaSeconds());
}

View file

@ -23,20 +23,6 @@ protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// APawn interface
virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
// End of APawn interface
// inputs
void InputForward(float Val);
void InputStrafe(float Val);
void InputLookX(float Rate);
void InputLookY(float Rate);
// mouse sensitivity multiplier (in effective degrees / sec)
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Camera)
float MouseSensitivityRate;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;

View file

@ -0,0 +1,59 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "FF.h"
#include "FFPlayerController.h"
// Called to bind functionality to input
void AFFPlayerController::SetupInputComponent()
{
// set up gameplay key bindings
// super checks
Super::SetupInputComponent();
// TODO: the base ACharacter jump handling kinda stinks
//InputComponent->BindAction("Jump", IE_Pressed, this, &AFFPlayerController::InputJump);
//InputComponent->BindAction("Jump", IE_Released, this, &AFFPlayerController::InputStopJumping);
InputComponent->BindAxis("Forward", this, &AFFPlayerController::Forward);
InputComponent->BindAxis("Strafe", this, &AFFPlayerController::Strafe);
InputComponent->BindAxis("LookX", this, &AFFPlayerController::LookX);
InputComponent->BindAxis("LookY", this, &AFFPlayerController::LookY);
MouseSensitivityRate = 150.0f;
}
void AFFPlayerController::Forward(float Value)
{
if (Value != 0.0f)
{
// add movement in that direction
//AddMovementInput(GetActorForwardVector(), Value);
}
}
void AFFPlayerController::Strafe(float Value)
{
if (Value != 0.0f)
{
// add movement in that direction
//AddMovementInput(GetActorRightVector(), Value);
}
}
void AFFPlayerController::LookX(float Rate)
{
// calculate delta for this frame from the rate information
//AddControllerYawInput(Rate * MouseSensitivityRate * GetWorld()->GetDeltaSeconds());
}
void AFFPlayerController::LookY(float Rate)
{
// calculate delta for this frame from the rate information
//AddControllerPitchInput(Rate * MouseSensitivityRate * GetWorld()->GetDeltaSeconds());
}
AFFCharacter* AFFPlayerController::GetFFCharacter()
{
// TODO:
return nullptr;
}

View file

@ -0,0 +1,36 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/PlayerController.h"
#include "FFCharacter.h"
#include "FFPlayerController.generated.h"
/**
*
*/
UCLASS()
class AFFPlayerController : public APlayerController
{
GENERATED_BODY()
private:
UPROPERTY()
AFFCharacter* FFCharacter;
// inputs
void Forward(float Val);
void Strafe(float Val);
void LookX(float Rate);
void LookY(float Rate);
public:
UFUNCTION(BlueprintCallable, Category = PlayerController)
virtual AFFCharacter* GetFFCharacter();
// mouse sensitivity multiplier (in effective degrees / sec)
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Camera)
float MouseSensitivityRate;
void SetupInputComponent() override;
};