You've already forked LuckyWorld
Rename entire project to LuckyWorldV2, including uproject file, folders and so on
This commit is contained in:
57
Source/LuckyWorldV2/TP_VehicleAdvPlayerController.cpp
Normal file
57
Source/LuckyWorldV2/TP_VehicleAdvPlayerController.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
|
||||
#include "TP_VehicleAdvPlayerController.h"
|
||||
#include "TP_VehicleAdvPawn.h"
|
||||
#include "TP_VehicleAdvUI.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "ChaosWheeledVehicleMovementComponent.h"
|
||||
|
||||
void ATP_VehicleAdvPlayerController::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
// spawn the UI widget and add it to the viewport
|
||||
VehicleUI = CreateWidget<UTP_VehicleAdvUI>(this, VehicleUIClass);
|
||||
|
||||
check(VehicleUI);
|
||||
|
||||
VehicleUI->AddToViewport();
|
||||
}
|
||||
|
||||
void ATP_VehicleAdvPlayerController::SetupInputComponent()
|
||||
{
|
||||
Super::SetupInputComponent();
|
||||
|
||||
// get the enhanced input subsystem
|
||||
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer()))
|
||||
{
|
||||
// add the mapping context so we get controls
|
||||
Subsystem->AddMappingContext(InputMappingContext, 0);
|
||||
|
||||
// optionally add the steering wheel context
|
||||
if (bUseSteeringWheelControls && SteeringWheelInputMappingContext)
|
||||
{
|
||||
Subsystem->AddMappingContext(SteeringWheelInputMappingContext, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ATP_VehicleAdvPlayerController::Tick(float Delta)
|
||||
{
|
||||
Super::Tick(Delta);
|
||||
|
||||
if (IsValid(VehiclePawn) && IsValid(VehicleUI))
|
||||
{
|
||||
VehicleUI->UpdateSpeed(VehiclePawn->GetChaosVehicleMovement()->GetForwardSpeed());
|
||||
VehicleUI->UpdateGear(VehiclePawn->GetChaosVehicleMovement()->GetCurrentGear());
|
||||
}
|
||||
}
|
||||
|
||||
void ATP_VehicleAdvPlayerController::OnPossess(APawn* InPawn)
|
||||
{
|
||||
Super::OnPossess(InPawn);
|
||||
|
||||
// get a pointer to the controlled pawn
|
||||
VehiclePawn = CastChecked<ATP_VehicleAdvPawn>(InPawn);
|
||||
}
|
Reference in New Issue
Block a user