Working on positionable crosshair
This commit is contained in:
@@ -21,3 +21,6 @@ ConnectionType=USBOnly
|
||||
bUseManualIPAddress=False
|
||||
ManualIPAddress=
|
||||
|
||||
[/Script/Engine.UserInterfaceSettings]
|
||||
UIScaleCurve=(EditorCurveData=(Keys=((Time=480.000000,Value=0.444000),(Time=720.000000,Value=0.666000),(Time=1080.000000,Value=1.000000),(Time=8640.000000,Value=8.000000)),DefaultValue=340282346638528859811704183484516925440.000000,PreInfinityExtrap=RCCE_Constant,PostInfinityExtrap=RCCE_Constant),ExternalCurve=None)
|
||||
|
||||
|
||||
BIN
Content/ConsoleBP.uasset
LFS
BIN
Content/ConsoleBP.uasset
LFS
Binary file not shown.
BIN
Content/LpxLevel.umap
LFS
BIN
Content/LpxLevel.umap
LFS
Binary file not shown.
BIN
Content/Luprex/Widgets/lxConsoleWidget.uasset
LFS
Normal file
BIN
Content/Luprex/Widgets/lxConsoleWidget.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/Widgets/lxCrosshairImage.uasset
LFS
Normal file
BIN
Content/Luprex/Widgets/lxCrosshairImage.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/Widgets/lxCrosshairWidget.uasset
LFS
Normal file
BIN
Content/Luprex/Widgets/lxCrosshairWidget.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/lxCrosshairImage.uasset
LFS
Normal file
BIN
Content/Luprex/lxCrosshairImage.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/Luprex/lxGameMode.uasset
LFS
BIN
Content/Luprex/lxGameMode.uasset
LFS
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -16,7 +16,7 @@
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
|
||||
USTRUCT(Blueprintable)
|
||||
USTRUCT(BlueprintType)
|
||||
struct INTEGRATION_API FlxAnimationStep {
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include "UtilityLibrary.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "Kismet/KismetSystemLibrary.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
|
||||
#define LOCTEXT_NAMESPACE "Luprex Utility"
|
||||
|
||||
@@ -73,3 +76,102 @@ UEnhancedInputLocalPlayerSubsystem *UlxUtilityLibrary::GetEnhancedInputLocalPlay
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// bool UlxUtilityLibrary::LineTraceMultipleLines(const AActor* ReferenceActor, const FVector &Offset,
|
||||
// const TArray<FlxTraceStartTraceEnd> &TraceStartAndTraceEnd, ETraceTypeQuery TraceChannel,
|
||||
// bool bTraceComplex, const TArray<AActor*>& ActorsToIgnore, EDrawDebugTrace::Type DrawDebugType, FHitResult& OutHit, bool bIgnoreReferenceActor,
|
||||
// FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime)
|
||||
// {
|
||||
// OutHit.Init();
|
||||
// OutHit.Distance = FLT_MAX;
|
||||
// FTransform ReferenceTransform = ReferenceActor->GetActorTransform();
|
||||
|
||||
// for (const FlxTraceStartTraceEnd &Points : TraceStartAndTraceEnd) {
|
||||
// FHitResult OneResult;
|
||||
// FVector TraceStart = ReferenceTransform.TransformPosition(Points.TraceStart + Offset);
|
||||
// FVector TraceEnd = ReferenceTransform.TransformPosition(Points.TraceEnd + Offset);
|
||||
// bool Found = UKismetSystemLibrary::LineTraceSingle(ReferenceActor, TraceStart, TraceEnd, TraceChannel, bTraceComplex,
|
||||
// ActorsToIgnore, DrawDebugType, OneResult, bIgnoreReferenceActor, TraceColor, TraceHitColor, DrawTime);
|
||||
// if (Found && (OneResult.Distance < OutHit.Distance))
|
||||
// {
|
||||
// OutHit = OneResult;
|
||||
// }
|
||||
// }
|
||||
// if (OutHit.Distance == FLT_MAX) {
|
||||
// OutHit.Distance = 0.0;
|
||||
// return false;
|
||||
// } else {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
bool UlxUtilityLibrary::LineTraceThroughMousePointer(const APlayerController* PlayerController,
|
||||
EMouseSpecificationType MouseSpecification, FVector2D ManualMouseXY, double MaxDistanceFromCamera,
|
||||
ETraceTypeQuery TraceChannel, bool bTraceComplex, EDrawDebugTrace::Type DrawDebugType, bool bIgnorePlayerPawn,
|
||||
const TArray<AActor*>& ActorsToIgnore, AActor *& Actor, FHitResult& HitResult)
|
||||
{
|
||||
const FLinearColor TraceColor = FLinearColor::Red;
|
||||
const FLinearColor TraceHitColor = FLinearColor::Green;
|
||||
const double DrawTime = 1.0;
|
||||
|
||||
// Zero out the return values.
|
||||
Actor = nullptr;
|
||||
HitResult.Init();
|
||||
|
||||
// Sanity check the distance.
|
||||
if (MaxDistanceFromCamera <= 0.0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure there's a player pawn.
|
||||
AActor *PlayerPawn = PlayerController->GetPawn();
|
||||
if (!PlayerPawn) return false;
|
||||
|
||||
// Get the Mouse XY.
|
||||
FVector2D MouseXY;
|
||||
switch (MouseSpecification)
|
||||
{
|
||||
case EMouseSpecificationType::GetMouseAutomatically:
|
||||
{
|
||||
double X, Y;
|
||||
if (!PlayerController->GetMousePosition(X, Y)) return false;
|
||||
MouseXY = FVector2D(X, Y);
|
||||
break;
|
||||
}
|
||||
case EMouseSpecificationType::SpecifyMouseInPixels:
|
||||
{
|
||||
MouseXY = ManualMouseXY;
|
||||
break;
|
||||
}
|
||||
case EMouseSpecificationType::SpecifyMouseAsZeroToOne:
|
||||
{
|
||||
int32 VX, VY;
|
||||
PlayerController->GetViewportSize(VX, VY);
|
||||
if ((VX == 0) || (VY == 0)) return false;
|
||||
MouseXY = ManualMouseXY * FVector2D(VX, VY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the trace start and trace end positions in world space.
|
||||
FVector WorldStart, WorldDirection, WorldEnd;
|
||||
if (!UGameplayStatics::DeprojectScreenToWorld(PlayerController, MouseXY, WorldStart, WorldDirection))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
WorldEnd = WorldStart + (WorldDirection * MaxDistanceFromCamera);
|
||||
|
||||
// Find the hit.
|
||||
if (UKismetSystemLibrary::LineTraceSingle(PlayerPawn, WorldStart, WorldEnd, TraceChannel, bTraceComplex,
|
||||
ActorsToIgnore, DrawDebugType, HitResult, bIgnorePlayerPawn, TraceColor, TraceHitColor, DrawTime))
|
||||
{
|
||||
Actor = HitResult.GetActor();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fail.
|
||||
Actor = nullptr;
|
||||
HitResult.Init();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/KismetSystemLibrary.h"
|
||||
|
||||
#include "UtilityLibrary.generated.h"
|
||||
|
||||
class UEnhancedInputLocalPlayerSubsystem;
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct INTEGRATION_API FlxTraceStartTraceEnd
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FVector TraceStart;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
FVector TraceEnd;
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EMouseSpecificationType : uint8
|
||||
{
|
||||
// Automatically get the mouse position from the player controller. ManualMouseXY should be left blank.
|
||||
GetMouseAutomatically,
|
||||
|
||||
// Specify the mouse position in pixels.
|
||||
SpecifyMouseInPixels,
|
||||
|
||||
// Specify the mouse position as float from zero to one.
|
||||
SpecifyMouseAsZeroToOne,
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* UlxUtilityLibrary is for functions that are aren't particularly luprex-specific,
|
||||
@@ -47,4 +74,23 @@ public:
|
||||
// enhanced input subsystem, return nullptr.
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="Player Controller|Local Player Subsystems")
|
||||
static UEnhancedInputLocalPlayerSubsystem *GetEnhancedInputLocalPlayerSubsystem(AController *Controller);
|
||||
|
||||
// // Do a Line Trace by Channel for each start-and-end pair, then return the closest hit result of all.
|
||||
// UFUNCTION(BlueprintCallable, Category="Collision", meta=(bIgnoreReferenceActor="true", AutoCreateRefTerm="ActorsToIgnore,Offset", DisplayName="Line Trace Multiple Lines by Channel", AdvancedDisplay="TraceColor,TraceHitColor,DrawTime", Keywords="raycast"))
|
||||
// static bool LineTraceMultipleLines(const AActor* ReferenceActor, const FVector &Offset,
|
||||
// const TArray<FlxTraceStartTraceEnd> &TraceStartAndTraceEnd, ETraceTypeQuery TraceChannel,
|
||||
// bool bTraceComplex, const TArray<AActor*>& ActorsToIgnore, EDrawDebugTrace::Type DrawDebugType, FHitResult& OutHit, bool bIgnoreReferenceActor,
|
||||
// FLinearColor TraceColor = FLinearColor::Red, FLinearColor TraceHitColor = FLinearColor::Green, float DrawTime = 5.0f);
|
||||
|
||||
// Do a Line Trace to find the actor that the mouse is pointing at.
|
||||
//
|
||||
// If you have some crosshairs in the viewport, then you can find the
|
||||
// object under the crosshairs by specifying the crosshairs XY as the
|
||||
// ManualMouseXY.
|
||||
//
|
||||
UFUNCTION(BlueprintCallable, Category="Collision", meta=(AutoCreateRefTerm="ActorsToIgnore", Keywords="raycast"))
|
||||
static bool LineTraceThroughMousePointer(const APlayerController* PlayerController,
|
||||
EMouseSpecificationType MouseSpecification, FVector2D ManualMouseXY, double MaxDistanceFromCamera,
|
||||
ETraceTypeQuery TraceChannel, bool bTraceComplex, EDrawDebugTrace::Type DrawDebugType, bool bIgnorePlayerPawn,
|
||||
const TArray<AActor*>& ActorsToIgnore, AActor *& Actor, FHitResult& HitResult);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user