You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
awesome_game/Source/TurnBasedTutorial/MyPlayerController.cpp

32 lines
939 B

// Fill out your copyright notice in the Description page of Project Settings.
#include "MyPlayerController.h"
AMyPlayerController::AMyPlayerController() : Super(), isMyTurn(false) {
UE_LOG(LogTemp, Warning, TEXT("Player controller created"));
}
void AMyPlayerController::SetupInputComponent() {
Super::SetupInputComponent();
InputComponent->BindAction("MyAction", IE_Pressed, this,
&AMyPlayerController::OnLeftMouseClick);
}
void AMyPlayerController::StartTurn() {
isMyTurn = true;
UE_LOG(LogTemp, Warning, TEXT("Your turn"));
}
void AMyPlayerController::EndTurn() {
isMyTurn = false;
UE_LOG(LogTemp, Warning, TEXT("Not your turn"));
}
void AMyPlayerController::OnLeftMouseClick() {
UE_LOG(LogTemp, Warning, TEXT("Mouse clicked"));
FHitResult HitResult;
bool IsHitResult = GetHitResultUnderCursorByChannel(TraceTypeQuery1, false, HitResult);
UE_LOG(LogTemp, Warning, TEXT("hitted: %s"), IsHitResult ? "Yes" : "No");
}