Compare commits
6 Commits
69ac5560f4
...
35dfb9f67c
Author | SHA1 | Date | |
---|---|---|---|
35dfb9f67c | |||
eb3f255098 | |||
cec5f2e90d | |||
a194605221 | |||
d3f2c03f48 | |||
6de68223f4 |
@ -2,6 +2,8 @@
|
||||
|
||||
[/Script/EngineSettings.GameMapsSettings]
|
||||
GameDefaultMap=/Engine/Maps/Templates/OpenWorld
|
||||
GameInstanceClass=/Game/Gamemodes/BP_TankGameinstance.BP_TankGameinstance_C
|
||||
GlobalDefaultGameMode=/Game/Gamemodes/BP_TankGamemode.BP_TankGamemode_C
|
||||
|
||||
[/Script/WindowsTargetPlatform.WindowsTargetSettings]
|
||||
DefaultGraphicsRHI=DefaultGraphicsRHI_DX12
|
||||
|
BIN
Content/Gamemodes/BP_TankGameinstance.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Gamemodes/BP_TankGameinstance.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Gamemodes/BP_TankGamemode.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Gamemodes/BP_TankGamemode.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Input/IA_Movement.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Input/IA_Movement.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Input/IA_Yaw.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Input/IA_Yaw.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Input/IMC_Player.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Input/IMC_Player.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Levels/Level.umap
(Stored with Git LFS)
Normal file
BIN
Content/Levels/Level.umap
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Player/BP_TankPlayerCharacter.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Player/BP_TankPlayerCharacter.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Player/BP_TankPlayerController.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Player/BP_TankPlayerController.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
5
Source/tank/TankGameInstance.cpp
Normal file
5
Source/tank/TankGameInstance.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "TankGameInstance.h"
|
||||
|
17
Source/tank/TankGameInstance.h
Normal file
17
Source/tank/TankGameInstance.h
Normal file
@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "TankGameInstance.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class TANK_API UTankGameInstance : public UGameInstance
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
74
Source/tank/TankPlayerCharacter.cpp
Normal file
74
Source/tank/TankPlayerCharacter.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "TankPlayerCharacter.h"
|
||||
|
||||
#include "TankPlayerController.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "InputMappingContext.h"
|
||||
|
||||
// Sets default values
|
||||
ATankPlayerCharacter::ATankPlayerCharacter()
|
||||
{
|
||||
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void ATankPlayerCharacter::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void ATankPlayerCharacter::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
}
|
||||
|
||||
// Called to bind functionality to input
|
||||
void ATankPlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
||||
{
|
||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||
|
||||
if (ATankPlayerController* TankPlayerController = Cast<ATankPlayerController>(GetController()))
|
||||
{
|
||||
if (UEnhancedInputLocalPlayerSubsystem* InputSystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(TankPlayerController->GetLocalPlayer()))
|
||||
{
|
||||
if (!InputMappingContext.IsNull())
|
||||
{
|
||||
InputSystem->AddMappingContext(InputMappingContext.LoadSynchronous(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (UEnhancedInputComponent* Input = Cast<UEnhancedInputComponent>(PlayerInputComponent))
|
||||
{
|
||||
if (MovementAction)
|
||||
{
|
||||
Input->BindAction(MovementAction, ETriggerEvent::Triggered, this, &ATankPlayerCharacter::MovementCallback);
|
||||
}
|
||||
|
||||
if (YawAction)
|
||||
{
|
||||
Input->BindAction(YawAction, ETriggerEvent::Triggered, this, &ATankPlayerCharacter::RotationCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ATankPlayerCharacter::MovementCallback(const FInputActionInstance& Instance)
|
||||
{
|
||||
float Movement = Instance.GetValue().Get<float>();
|
||||
AddMovementInput(GetActorForwardVector(), Movement);
|
||||
}
|
||||
|
||||
void ATankPlayerCharacter::RotationCallback(const FInputActionInstance& Instance)
|
||||
{
|
||||
float Rotation = Instance.GetValue().Get<float>();
|
||||
AddControllerYawInput(Rotation);
|
||||
}
|
||||
|
52
Source/tank/TankPlayerCharacter.h
Normal file
52
Source/tank/TankPlayerCharacter.h
Normal file
@ -0,0 +1,52 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "TankPlayerCharacter.generated.h"
|
||||
|
||||
class UInputMappingContext;
|
||||
class UInputAction;
|
||||
|
||||
UCLASS()
|
||||
class TANK_API ATankPlayerCharacter : public ACharacter
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TSoftObjectPtr<UInputMappingContext> InputMappingContext;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
UInputAction* MovementAction;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
UInputAction* YawAction;
|
||||
|
||||
public:
|
||||
// Sets default values for this character's properties
|
||||
ATankPlayerCharacter();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
private:
|
||||
|
||||
UFUNCTION()
|
||||
void MovementCallback(const FInputActionInstance& Instance);
|
||||
|
||||
UFUNCTION()
|
||||
void RotationCallback(const FInputActionInstance& Instance);
|
||||
|
||||
};
|
5
Source/tank/TankPlayerController.cpp
Normal file
5
Source/tank/TankPlayerController.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "TankPlayerController.h"
|
||||
|
17
Source/tank/TankPlayerController.h
Normal file
17
Source/tank/TankPlayerController.h
Normal file
@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "TankPlayerController.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class TANK_API ATankPlayerController : public APlayerController
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user