I’m following some Udemy tutorials, and I got to a point where it wants us to generate a debug position visual using DrawDebugSphere. Following the guidance of the tutorial however, I cannot seem to get it to work. I don’t receive any errors at all - just nothing renders.
To debug this and figure it out, I’ve created an entire stand-alone First Person project with only this SceneComponent added to the project. When I add this code to a blueprint and I press my action button that calls the DrawTest function, the output of “Test!” does display in the console, however I don’t see any debug sphere drawn in the world at all. I’ve tried a handful of different distances (40, 400) and no luck.
Could someone please advise on what I’m doing wrong? Thank you!
.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/SceneComponent.h"
#include "DebugVisualTester.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class HOPEFULLYNOTCORRUPT_API UDebugVisualTester : public USceneComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UDebugVisualTester();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
UFUNCTION(BlueprintCallable)
void DrawTest();
};
.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "DebugVisualTester.h"
// Sets default values for this component's properties
UDebugVisualTester::UDebugVisualTester()
{
// 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.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UDebugVisualTester::BeginPlay()
{
Super::BeginPlay();
// ...
}
// Called every frame
void UDebugVisualTester::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
void UDebugVisualTester::DrawTest()
{
FVector Start = GetComponentLocation();
FVector End = Start * 40;
DrawDebugSphere(GetWorld(), End, 10, 10, FColor::Blue, true, 5);
UE_LOG(LogTemp, Display, TEXT("Test!"));
}