Skip to content

Commit

Permalink
#37 Added blueprint/console parameters for debug lines
Browse files Browse the repository at this point in the history
  • Loading branch information
xthebat committed Nov 2, 2023
1 parent c9d9e2d commit f446cf6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 39 deletions.
13 changes: 7 additions & 6 deletions Config/DefaultGame.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[/Script/EngineSettings.GeneralProjectSettings]
ProjectID=BACFB3F848AE10EDFB548D9F7BDABCA4
ProjectName=Cloud9
ProjectID = BACFB3F848AE10EDFB548D9F7BDABCA4
ProjectName = Cloud9

[/Script/Cloud9.Cloud9Character]
FixedCameraPitch=-45.0
FixedCameraDistance=1500.0
FixedCameraPitch = -45.0
FixedCameraDistance = 1500.0
bIsDrawHitCursorLine = false

[StartupActions]
bAddPacks=True
InsertPack=(PackSource="StarterContent.upack",PackName="StarterContent")
bAddPacks = True
InsertPack = (PackSource="StarterContent.upack",PackName="StarterContent")

Binary file modified Content/Blueprints/Character/BP_Cloud9Character.uasset
Binary file not shown.
Binary file modified Content/Blueprints/Game/BP_Cloud9Console.uasset
Binary file not shown.
67 changes: 35 additions & 32 deletions Source/Cloud9/Character/Cloud9Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const FName ACloud9Character::InventoryComponentName = TEXT("Inventory");
ACloud9Character::ACloud9Character(const FObjectInitializer& ObjectInitializer) : Super(
ObjectInitializer.SetDefaultSubobjectClass<UCloud9CharacterMovement>(CharacterMovementComponentName))
{
bIsDrawHitCursorLine = false;
bIsDrawDeprojectedCursorLine = false;

bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
Expand Down Expand Up @@ -107,38 +110,38 @@ void ACloud9Character::SetViewDirection(const FHitResult& HitResult, bool bIsHit
SetCursorIsHidden(false);
}

FVector WorldLocation;
FVector WorldDirection;
FVector2D MousePosition;

GetCloud9Controller()->GetMousePosition(MousePosition.X, MousePosition.Y);
GetCloud9Controller()->DeprojectScreenPositionToWorld(
MousePosition.X,
MousePosition.Y,
WorldLocation,
WorldDirection);

DrawDebugLine(
GetWorld(),
GetActorLocation(),
WorldLocation,
FColor::Red,
false,
/*LifeTime=*/0.0,
/*DepthPriority=*/0,
/*Thickness=*/0.f);

DrawDebugLine(
GetWorld(),
GetActorLocation(),
HitResult.Location,
FColor::Green,
false,
/*LifeTime=*/0.0,
/*DepthPriority=*/0,
/*Thickness=*/0.f);

// UE_LOG(LogCloud9, Display, TEXT("%s"), *HitResult.Location.ToString());
if (bIsDrawHitCursorLine)
{
DrawDebugLine(
GetWorld(),
GetActorLocation(),
HitResult.Location,
FColor::Green,
false,
0.0);
}

if (bIsDrawDeprojectedCursorLine)
{
FVector WorldLocation;
FVector WorldDirection;
FVector2D MousePosition;

GetCloud9Controller()->GetMousePosition(MousePosition.X, MousePosition.Y);
GetCloud9Controller()->DeprojectScreenPositionToWorld(
MousePosition.X,
MousePosition.Y,
WorldLocation,
WorldDirection);

DrawDebugLine(
GetWorld(),
GetActorLocation(),
WorldLocation,
FColor::Red,
false,
0.0);
}

if (bIsHitValid)
{
Expand Down
17 changes: 16 additions & 1 deletion Source/Cloud9/Character/Cloud9Character.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "Cloud9Character.generated.h"


UCLASS(Blueprintable)
UCLASS(config=Game, Blueprintable)
class ACloud9Character : public ACharacter
{
GENERATED_BODY()
Expand Down Expand Up @@ -61,6 +61,21 @@ class ACloud9Character : public ACharacter
UPROPERTY(BlueprintReadOnly, Category=Character)
uint32 bIsSneaking : 1;

// Debug section

UFUNCTION(BlueprintCallable)
void SetIsDrawHitCursorLine(bool Value) { bIsDrawHitCursorLine = Value; }

UFUNCTION(BlueprintCallable)
void SetIsDrawDeprojectedCursorLine(bool Value) { bIsDrawDeprojectedCursorLine = Value; }

protected:
UPROPERTY(Config, BlueprintReadOnly, Category = Debug)
bool bIsDrawHitCursorLine;

UPROPERTY(Config, BlueprintReadOnly, Category = Debug)
bool bIsDrawDeprojectedCursorLine;

private:
UPROPERTY(EditDefaultsOnly)
UMaterial* CursorDecal;
Expand Down

0 comments on commit f446cf6

Please sign in to comment.