Refactored TempCharacter code
This commit is contained in:
parent
2c7a717617
commit
f632a010a4
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:f4a37ec4a9d65f2b21c7e29d31fb9b9dd998e181aa264ca826aa1e6594da30ef
|
oid sha256:1ef2465e4c7f6a5910df3ec5a3923c9a0f80eb17ddb1411de806275274b50ba1
|
||||||
size 23329
|
size 24707
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include "../../../Plugins/Developer/RiderLink/Source/RD/thirdparty/clsocket/src/ActiveSocket.h"
|
#include "../../../Plugins/Developer/RiderLink/Source/RD/thirdparty/clsocket/src/ActiveSocket.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// CONSTRUCTOR
|
// CONSTRUCTOR
|
||||||
ATempCharacter::ATempCharacter()
|
ATempCharacter::ATempCharacter()
|
||||||
{
|
{
|
||||||
@ -23,13 +22,13 @@ void ATempCharacter::BeginPlay()
|
|||||||
//Binds the input we made in the setup player component to the forward vector
|
//Binds the input we made in the setup player component to the forward vector
|
||||||
void ATempCharacter::ForwardInput(float Axis)
|
void ATempCharacter::ForwardInput(float Axis)
|
||||||
{
|
{
|
||||||
AddMovementInput(GetActorForwardVector()* Axis);
|
AddMovementInput(GetActorForwardVector() * Axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Binds the input we made in the setup player component to the right vector
|
//Binds the input we made in the setup player component to the right vector
|
||||||
void ATempCharacter::RightMoveInput(float Axis)
|
void ATempCharacter::RightMoveInput(float Axis)
|
||||||
{
|
{
|
||||||
AddMovementInput(GetActorRightVector()* Axis);
|
AddMovementInput(GetActorRightVector() * Axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -47,30 +46,33 @@ void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo
|
|||||||
PlayerInputComponent->BindAxis(TEXT("Move Right / Left"), this, &ATempCharacter::RightMoveInput);
|
PlayerInputComponent->BindAxis(TEXT("Move Right / Left"), this, &ATempCharacter::RightMoveInput);
|
||||||
PlayerInputComponent->BindAxis(TEXT("Turn Right / Left Mouse"), this, &ATempCharacter::AddControllerYawInput);
|
PlayerInputComponent->BindAxis(TEXT("Turn Right / Left Mouse"), this, &ATempCharacter::AddControllerYawInput);
|
||||||
PlayerInputComponent->BindAxis(TEXT("Look Up / Down Mouse"), this, &ATempCharacter::AddControllerPitchInput);
|
PlayerInputComponent->BindAxis(TEXT("Look Up / Down Mouse"), this, &ATempCharacter::AddControllerPitchInput);
|
||||||
PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed); // custom keybind Interact
|
PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed);
|
||||||
|
// custom keybind Interact
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATempCharacter::KeyPressed()
|
void ATempCharacter::KeyPressed()
|
||||||
{
|
{
|
||||||
//vars for LineTraceSingleByChannel
|
LineTraceLogic();
|
||||||
TraceDistance = 1000;
|
}
|
||||||
FHitResult Hit;
|
|
||||||
|
void ATempCharacter::LineTraceLogic()
|
||||||
|
{
|
||||||
|
float GlobalTrace = TraceDistance;
|
||||||
|
FHitResult OutHit;
|
||||||
FVector Start = GetActorLocation();
|
FVector Start = GetActorLocation();
|
||||||
FVector End = Start + TraceDistance * GetActorForwardVector();
|
FVector End = Start + GlobalTrace * GetActorForwardVector();
|
||||||
|
|
||||||
FCollisionQueryParams TraceParams;
|
FCollisionQueryParams TraceParams;
|
||||||
|
|
||||||
TraceParams.AddIgnoredActor(this);
|
TraceParams.AddIgnoredActor(this);
|
||||||
|
|
||||||
bool bHit = GetWorld()->LineTraceSingleByChannel(Hit,Start,End,ECC_Visibility, TraceParams);
|
bool bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Visibility, TraceParams);
|
||||||
if(bHit)
|
if (bHit)
|
||||||
{
|
{
|
||||||
if(Hit.GetActor()->ActorHasTag("MerchantTag"))
|
if (OutHit.GetActor()->ActorHasTag("MerchantTag"))
|
||||||
{
|
{
|
||||||
DrawDebugLine(GetWorld(),Start, End, FColor::Green, false, 1.0f);
|
DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f);
|
||||||
UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *Hit.GetActor()->GetName());
|
UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -22,8 +22,6 @@ protected:
|
|||||||
void ForwardInput(float Axis);
|
void ForwardInput(float Axis);
|
||||||
void RightMoveInput(float Axis);
|
void RightMoveInput(float Axis);
|
||||||
|
|
||||||
float TraceDistance;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
@ -32,4 +30,10 @@ public:
|
|||||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||||
|
|
||||||
void KeyPressed();
|
void KeyPressed();
|
||||||
|
|
||||||
|
UPROPERTY(EditAnyWhere)
|
||||||
|
float TraceDistance = 200;
|
||||||
|
|
||||||
|
void LineTraceLogic();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user