AzureAbyss/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp

92 lines
2.8 KiB
C++
Raw Normal View History

// Fill out your copyright notice in the Description page of Project Settings.
#include "TempCharacter.h"
#include "../../../Plugins/Developer/RiderLink/Source/RD/thirdparty/clsocket/src/ActiveSocket.h"
2022-11-10 12:57:31 +00:00
// CONSTRUCTOR
ATempCharacter::ATempCharacter()
{
// 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 ATempCharacter::BeginPlay()
{
Super::BeginPlay();
}
2022-11-10 12:57:31 +00:00
//Binds the input we made in the setup player component to the forward vector
void ATempCharacter::ForwardInput(float Axis)
{
AddMovementInput(GetActorForwardVector()* Axis);
}
2022-11-10 12:57:31 +00:00
//Binds the input we made in the setup player component to the right vector
void ATempCharacter::RightMoveInput(float Axis)
{
AddMovementInput(GetActorRightVector()* Axis);
}
2022-11-10 12:57:31 +00:00
// Called every frame
void ATempCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis(TEXT("Move Forward / Backward"), this, &ATempCharacter::ForwardInput);
PlayerInputComponent->BindAxis(TEXT("Move Right / Left"), this, &ATempCharacter::RightMoveInput);
PlayerInputComponent->BindAxis(TEXT("Turn Right / Left Mouse"), this, &ATempCharacter::AddControllerYawInput);
PlayerInputComponent->BindAxis(TEXT("Look Up / Down Mouse"), this, &ATempCharacter::AddControllerPitchInput);
2022-11-10 12:57:31 +00:00
PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed); // custom keybind Interact
}
/*
TODO:
Make custom bool for pressed interact in trigger
Make custom bool for when player enters the trigger its set to true
Make if statement if both flags are true then dilouge box pops up
*/
void ATempCharacter::KeyPressed(FKey Interact)
{
//vars for LineTraceSingleByChannel
TraceDistance = 1000;
FHitResult Hit;
FRotator Rot;
FVector Location;
FVector Start = Location;
FVector End = Start + (Rot.Vector() * TraceDistance);
GetController()->GetPlayerViewPoint(Location, Rot); // where the player is looking thats what we set the location/rotation too
FCollisionQueryParams TraceParams;
bool bHit = GetWorld()->LineTraceSingleByChannel(Hit,Start,End,ECC_Visibility, TraceParams);
if(bHit)
{
DrawDebugLine(GetWorld(),Start, End, FColor::Green, false, 1.0f);
UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *Hit.GetActor()->GetName());
//Hit.GetActor()->Destroy();
}
else
{
UE_LOG(LogTemp, Display, TEXT("BHIT IS FALSE"));
}
/*
TODO:
FIX IT SO THE TRACE IS NOT HITTING PLANE
ITS HITTING PLANE NO MATTER WHAT MAYBE FIX LOCATION OF WHERE ITS BEING SHOT FROM?
*/
}