DrawDebugCone draws cone with improper height

Method DrawDebugCone from DrawDebugHelpers.h is really a good example of how NOT to write code.

  1. There is ambiguity in angle parameter. It could be degrees or radians
  2. There is ambiguity in length parameter. It could be height or length of edge.

Apart of that it also probably doesn’t work as expected. From inspecting code I see that angles is in radians (but I shouldn’t have to do that, name of parameter should be enough), but (2) is a mystery. I’ ve tried both soulutions, to treat “length” as height and as edge length but I cannot draw cone with proper height. Those are my tries:

as edge length:

DrawDebugCone(UGameUtils::GetGameWorld(), m_Cone.m_ConePosition, m_Cone.m_ConeDirection, m_Cone.m_ConeHeight / UKismetMathLibrary::DegCos(m_Cone.m_ConeHalfDegrees), FMath::DegreesToRadians(m_Cone.m_ConeHalfDegrees * 2.f), FMath::DegreesToRadians(m_Cone.m_ConeHalfDegrees * 2.f), 80, FColor::Red, false, 1.f);

as height:

DrawDebugCone(UGameUtils::GetGameWorld(), m_Cone.m_ConePosition, m_Cone.m_ConeDirection, m_Cone.m_ConeHeight, FMath::DegreesToRadians(m_Cone.m_ConeHalfDegrees * 2.f), FMath::DegreesToRadians(m_Cone.m_ConeHalfDegrees * 2.f), 80, FColor::Red, false, 1.f);

Am I doing something wrong or is it a bug?

thanks

Hi Buyaka,

We were already aware of the possible confusion related to the DrawDebugCone function taking radians instead of degrees, and we have updated the comment for the function to better reflect that. You should see that in a future version of the Engine.

I am a little bit unsure of the confusion regarding the height of the cone, though. Would you be able to better describe what you are trying to achieve? I created two cones with identical settings, except one has a half-angle of 30 degrees and the other a half-angle of 60 degrees. Then I used both of the function calls you provided to see what the difference would be.

65754-cones.png

The blue cones use the first function call you provided and the red cones use the second function call. It would appear that if you want to be able to specify a specific height for a cone, you would want to use the first call since both of those cones are the same height even though their angles are different. Am I misunderstanding what the issue is?

There really should be a simpler function with just radius and height.
I spent 20 minutes fiddling with this function trying to figure out what the different parameters were, and I assume everybody does since drawing a non-regular cone is clearly not the most common thing you want to draw.

1 Like

I have the same problem, can’t quite understand how the DrawDebugCone should supposed to work, and I’m getting burrito shapes instead of cones.

Here is my code:

DrawDebugCone(GetWorld(), CameraPosition, CameraDirection, 1000, FMath::DegreesToRadians(30), FMath::DegreesToRadians(90), 1500, FColor::Red, true, 10000, 0, 1);
				DrawDebugCone(GetWorld(), CameraPosition, CameraDirection, 1000, FMath::DegreesToRadians(60), FMath::DegreesToRadians(90), 1500, FColor::Blue, true, 10000, 0, 1);

Here are the results:


Here is what I’m trying to achieve, a normal cone:
marija1.1

What am I doing wrong?