diff --git a/Config/DefaultInput.ini b/Config/DefaultInput.ini index 4c7579d..f64b2e7 100644 --- a/Config/DefaultInput.ini +++ b/Config/DefaultInput.ini @@ -87,10 +87,10 @@ DefaultViewportMouseLockMode=LockOnCapture FOVScale=0.011110 DoubleClickTime=0.200000 +ActionMappings=(ActionName="Fire",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton) -+AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=W) -+AxisMappings=(AxisName="MoveForward",Scale=-1.000000,Key=S) -+AxisMappings=(AxisName="Turn",Scale=1.000000,Key=D) -+AxisMappings=(AxisName="Turn",Scale=-1.000000,Key=A) ++AxisMappings=(AxisName="MoveForward",Scale=4.000000,Key=W) ++AxisMappings=(AxisName="MoveForward",Scale=-4.000000,Key=S) ++AxisMappings=(AxisName="Turn",Scale=4.000000,Key=D) ++AxisMappings=(AxisName="Turn",Scale=-4.000000,Key=A) +AxisMappings=(AxisName="RotateTurret",Scale=1.000000,Key=MouseX) DefaultPlayerInputClass=/Script/EnhancedInput.EnhancedPlayerInput DefaultInputComponentClass=/Script/EnhancedInput.EnhancedInputComponent diff --git a/Content/Maps/Main.umap b/Content/Maps/Main.umap index 75277b4..6a5fd8c 100644 Binary files a/Content/Maps/Main.umap and b/Content/Maps/Main.umap differ diff --git a/Source/ToonTanks/BasePawn.cpp b/Source/ToonTanks/BasePawn.cpp index c3b407a..67ebb79 100644 --- a/Source/ToonTanks/BasePawn.cpp +++ b/Source/ToonTanks/BasePawn.cpp @@ -36,12 +36,8 @@ void ABasePawn::Tick(float DeltaTime) { Super::Tick(DeltaTime); -} - -// Called to bind functionality to input -void ABasePawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) -{ - Super::SetupPlayerInputComponent(PlayerInputComponent); + /*FVector DeltaLocation(0.f); + DeltaLocation.X = 2.f; + AddActorLocalOffset(DeltaLocation);*/ } - diff --git a/Source/ToonTanks/BasePawn.h b/Source/ToonTanks/BasePawn.h index 268edf1..fa14567 100644 --- a/Source/ToonTanks/BasePawn.h +++ b/Source/ToonTanks/BasePawn.h @@ -61,7 +61,4 @@ public: // Called every frame virtual void Tick(float DeltaTime) override; - // Called to bind functionality to input - virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; - }; diff --git a/Source/ToonTanks/Tank.cpp b/Source/ToonTanks/Tank.cpp index 2db8f3b..159e8b4 100644 --- a/Source/ToonTanks/Tank.cpp +++ b/Source/ToonTanks/Tank.cpp @@ -4,12 +4,41 @@ #include "Tank.h" #include "GameFramework/SpringArmComponent.h" #include "Camera/CameraComponent.h" +#include "Components/InputComponent.h" ATank::ATank() { + SpringArm = CreateDefaultSubobject(TEXT("Spring Arm")); SpringArm->SetupAttachment(RootComponent); Camera = CreateDefaultSubobject(TEXT("Camera")); Camera->SetupAttachment(SpringArm); + +} + +void ATank::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) +{ + + Super::SetupPlayerInputComponent(PlayerInputComponent); + + PlayerInputComponent->BindAxis(TEXT("MoveForward"), this, &ATank::Move); + PlayerInputComponent->BindAxis(TEXT("Turn"), this, &ATank::Turn); + + +} + +void ATank::Move(float Value) +{ + //FVector DeltaLocation(0.f); //Same as line below + FVector DeltaLocation = FVector::ZeroVector; + DeltaLocation.X = Value; + AddActorLocalOffset(DeltaLocation); + //UE_LOG(LogTemp, Warning, TEXT("Value: %f"), Value); +} + +void ATank::Turn(float TValue) +{ + //UE_LOG(LogTemp, Warning, TEXT("Value: %f"), TValue); + } \ No newline at end of file diff --git a/Source/ToonTanks/Tank.h b/Source/ToonTanks/Tank.h index fdb6d87..aeab67e 100644 --- a/Source/ToonTanks/Tank.h +++ b/Source/ToonTanks/Tank.h @@ -17,10 +17,16 @@ class TOONTANKS_API ATank : public ABasePawn public: ATank(); + // Called to bind functionality to input + virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + private: UPROPERTY(VisibleAnywhere, Category = "Components") class USpringArmComponent* SpringArm; UPROPERTY(VisibleAnywhere, Category = "Components") class UCameraComponent* Camera; + + void Move(float Value); + void Turn(float TValue); };