Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copyright ©2015 Austin R. Snider and Brandon L. Snider; do not copy modify or distribute without permisson.
- #include "DragonsLair.h"
- #include "DragonsLairPlayerController.h"
- #include "Engine.h"
- ADragonsLairPlayerController::ADragonsLairPlayerController(const FObjectInitializer& ObjectInitializer)
- {
- }
- void ADragonsLairPlayerController::BeginPlay()
- {
- PlayerCharacterRef = Cast<APlayerCharacter>(GetPawn());
- PlayerCameraRef = PlayerCharacterRef->PlayerCameraRef;
- }
- void ADragonsLairPlayerController::SetupInputComponent()
- {
- Super::SetupInputComponent();
- InputComponent->BindAxis("MoveForwardAxis", this, &ADragonsLairPlayerController::MoveForwardAxis);
- InputComponent->BindAxis("MoveSideAxis", this, &ADragonsLairPlayerController::MoveSideAxis);
- InputComponent->BindAxis("LookVertical", this, &ADragonsLairPlayerController::LookVertical);
- InputComponent->BindAxis("LookHorizontal", this, &ADragonsLairPlayerController::LookHorizontal);
- InputComponent->BindAxis("LeftInteract", this, &ADragonsLairPlayerController::LeftInteract);
- InputComponent->BindAxis("RightInteract", this, &ADragonsLairPlayerController::RightInteract);
- InputComponent->BindAction("SwitchItem1", IE_Pressed, this, &ADragonsLairPlayerController::SwitchItem1);
- InputComponent->BindAction("SwitchItem2", IE_Pressed, this, &ADragonsLairPlayerController::SwitchItem2);
- InputComponent->BindAction("SwitchItem3", IE_Pressed, this, &ADragonsLairPlayerController::SwitchItem3);
- InputComponent->BindAction("SwitchPreviousItem", IE_Pressed, this, &ADragonsLairPlayerController::SwitchPreviousItem);
- InputComponent->BindAction("SwitchNextItem", IE_Pressed, this, &ADragonsLairPlayerController::SwitchNextItem);
- InputComponent->BindAction("UseItem", IE_Pressed, this, &ADragonsLairPlayerController::SwitchItem1);
- InputComponent->BindAction("UseShield", IE_Pressed, this, &ADragonsLairPlayerController::SwitchItem2);
- }
- void ADragonsLairPlayerController::MoveForwardAxis(float AxisValue)
- {
- if (PlayerCharacterRef != nullptr)
- {
- FVector CharacterForwardVector = PlayerCharacterRef->GetActorForwardVector();
- FVector MovementInputVector = CharacterForwardVector * PlayerCharacterRef->MovementSpeed;
- PlayerCharacterRef->AddMovementInput(MovementInputVector, AxisValue);
- }
- else
- {
- GEngine->AddOnScreenDebugMessage(0, 10, FColor::Blue, "PlayerCharRef == nullptr");
- PlayerCharacterRef = Cast<APlayerCharacter>(GetPawn());
- }
- }
- void ADragonsLairPlayerController::MoveSideAxis(float AxisValue)
- {
- if (PlayerCharacterRef != nullptr)
- {
- FVector CharacterRightVector = PlayerCharacterRef->GetActorRightVector();
- FVector MovementInputVector = CharacterRightVector * PlayerCharacterRef->MovementSpeed;
- PlayerCharacterRef->AddMovementInput(MovementInputVector, AxisValue);
- }
- else
- {
- GEngine->AddOnScreenDebugMessage(0, 10, FColor::Blue, "PlayerCharRef == nullptr");
- PlayerCharacterRef = Cast<APlayerCharacter>(GetPawn());
- }
- }
- void ADragonsLairPlayerController::LookVertical(float AxisValue)
- {
- if (PlayerCharacterRef != nullptr)
- {
- FRotator DeltaRotation = FRotator(AxisValue, 0.0f, 0.0f);
- PlayerCameraRef->AddLocalRotation(DeltaRotation);
- }
- else
- {
- GEngine->AddOnScreenDebugMessage(0, 10, FColor::Blue, "PlayerCharRef == nullptr");
- PlayerCharacterRef = Cast<APlayerCharacter>(GetPawn());
- }
- }
- void ADragonsLairPlayerController::LookHorizontal(float AxisValue)
- {
- if (PlayerCharacterRef != nullptr)
- {
- FRotator DeltaRotation = FRotator(0.0f, AxisValue, 0.0f);
- PlayerCharacterRef->AddActorLocalRotation(DeltaRotation);
- }
- else
- {
- GEngine->AddOnScreenDebugMessage(0, 10, FColor::Blue, "PlayerCharRef == nullptr");
- PlayerCharacterRef = Cast<APlayerCharacter>(GetPawn());
- }
- }
- void ADragonsLairPlayerController::LeftInteract(float AxisValue)
- {
- }
- void ADragonsLairPlayerController::RightInteract(float AxisValue)
- {
- }
- void ADragonsLairPlayerController::SwitchItem1()
- {
- }
- void ADragonsLairPlayerController::SwitchItem2()
- {
- }
- void ADragonsLairPlayerController::SwitchItem3()
- {
- }
- void ADragonsLairPlayerController::SwitchPreviousItem()
- {
- }
- void ADragonsLairPlayerController::SwitchNextItem()
- {
- }
- void ADragonsLairPlayerController::UseItem()
- {
- }
- void ADragonsLairPlayerController::UseShield()
- {
- }
- void ADragonsLairPlayerController::Interact()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement