DrawDebugCone only draws a line (Blueprint)

Branch: Binary
Version: 4.4.1-2270799 (and older)

Description: Using the ‘DrawDebugCone’ Blueprint node only draws a line of ‘Length’ - no cone is visible. I’m trying to use it to draw the perception cone for one of my actors and have not found any combination of values that draws anything other than a line.

Repro:

  1. In any blueprint, create a DrawDebugCone node in the EventGraph and attach it to desired location/direction.
  2. Set ‘Angle Width’, ‘Angle Height’, and ‘Length’ to desired values.
  3. Compile and play. Note that only a line from ‘Origin’ of size ‘Length’ is drawn.
1 Like

On further testing I just realized it’s also drawing the line the opposite direction of the vector given. I hook it up to the actor’s forward vector and the line draws in -X instead of +X.

yep i get this… what gives ?

Hello Chambered,

Thank you for all of your information and time. I was able to go back and reproduce this issue on the version of the engine that you have mentioned. However, I wanted to post an update saying that I have tested this feature in the current version of the engine (4.6) and I have found that it has been fixed.

Make it a great day.

This bug still exists in the version of 4.8. When DrawDebugCone is called in C++, the exact problem happens. Here is my code:

void FXVisualizer::DrawLineArrow(FVector &start, FVector &end, FLinearColor color)
{
	UWorld *world = GEditor->GetEditorWorldContext().World();
	FVector dir = start - end;
	DrawDebugCone(world, end, dir, 50.0f, 30.0f, 30.0f, 16, color, false, 0.5f);
}

Hi Li,

This isn’t really a bug, but more that the source code isn’t really clear about the parameters being passed to DrawDebugCone(). The angular values being passed into DrawDebugCone() should be in radians, not in degrees. Since the function is expecting radians, any angular value over 2π is drawn as a straight line in the opposite direction to where you expect your cone to be facing. I have entered a feature request to see if we can make this a bit clearer in the future (UE-18862).

In the meantime, there are a couple options to get this to work for you. The first would be to do the conversion yourself and enter radian values instead of degree values. So your function call would look something like this (I am approximating the radian value for 30 degrees):

DrawDebugCone(world, end, dir, 50.f, 0.5f, 0.5f, 16, FLinearColor::White, false, 0.5f);

If you prefer not to have to do the conversion to radians, the Engine can take care of that for you, and your function call would look something like this:

DrawDebugCone(world, start, dir, 50.f, FMath::DegreesToRadians(30.f), FMath::DegreesToRadians(30.f), 16, FLinearColor::White, false, 0.5f);
3 Likes

Hi :

Yes it works. Thank you for your clear answer.

Hi ,

Just a quick update for you on this. The feature request that I entered to clarify that radians are needed for the function call has been implemented. There is now a comment for this function in the source code (previously there was no comment at all) that lets you know that radians are expected here.

If you have built your Engine from source code, and want to integrate this change yourself, you can merge in this commit from GitHub. If you are using the binary version of the Engine installed through the Launcher, you will see this change in a future release version of the Engine.