Debug line doesn't change direction and only draws in the x axis

Hi guys,


strange one here.

// Fill out your copyright notice in the Description page of Project Settings.

#include “Grabber.h”
#include “Engine/World.h”
#include “DrawDebugHelpers.h”
#include “GameFramework/PlayerController.h”

#define OUT

// Sets default values for this component’s properties
UGrabber::UGrabber()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don’t need them.
// bWantsBeginPlay = true;
PrimaryComponentTick.bCanEverTick = true;

// ...

}

// Called when the game starts
void UGrabber::BeginPlay()
{
Super::BeginPlay();

UE_LOG(LogTemp, Warning, TEXT("Grabber reporting for duty!"));

}

// Called every frame
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

// Get player viewpoint this tick
FVector PlayerViewPointLocation;
FRotator PlayerViewPointRotation;
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(
	OUT PlayerViewPointLocation,
	OUT PlayerViewPointRotation
);
// vv doesn't work this way vv
// FString PlayerLocation = PlayerViewPointLocation.ToString();
// FString PlayerRotation = PlayerViewPointRotation.ToString();

UE_LOG(LogTemp, Warning, TEXT("Location: %s, Rotation: %s"), 
	*PlayerViewPointLocation.ToString(), 
	*PlayerViewPointRotation.ToString()
);

/*FVector LineTraceEnd = PlayerViewPointLocation + FVector(0.f, 0.f, 50.f);*/
FVector LineTraceEnd = (PlayerViewPointLocation + PlayerViewPointRotation.Vector()) * Reach;

DrawDebugLine(
	GetWorld(),
	PlayerViewPointLocation,
	LineTraceEnd,
	FColor(255, 0, 0),
	false,
	0.f,
	0.f,
	5.f
);

// Ray-cast out to reach distance

// See what we hit

}

Solved. Reduced the Reach to 50.f and it seems to behave.

Privacy & Terms