44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#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);
|
|
|
|
} |