Tank Movement
This commit is contained in:
@@ -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);*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
@@ -4,12 +4,41 @@
|
||||
#include "Tank.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Components/InputComponent.h"
|
||||
|
||||
ATank::ATank()
|
||||
{
|
||||
|
||||
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Spring Arm"));
|
||||
SpringArm->SetupAttachment(RootComponent);
|
||||
|
||||
Camera = CreateDefaultSubobject<UCameraComponent>(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);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user