Is inside the cone

Hey! I’m trying to determine if a certain location is inside the cone of a spotlight.
So I found this method :FMath::GetDistanceWithinConeSegment | Unreal Engine Documentation.

Here is what I do

However, it is currently not working…
I could (and will probably) do a normal LineTrace and check the angle between both locations, but I wanted to know what I was doing wrong.

Your parameters must be bad, either that or the engine implementation has a bug.

And it seems the fifth argument is wrong, it’s supposed to be the actual radius of the cone, not the angle of it. Maybe the third parameter is wrong as well depending on what AttenuationRadius refers to. The way you have it now OuterConeAngle is probably way smaller than what it should be. So you’ll first have to compute the value for the fifth argument based on the other values you have.
It should be something along the lines of

float Exposition;
FVector ConeLine = LightComp->AttenuationRadius * LightComp->GetOwner()->GetActorForwardVector();
float RadiusAtEnd = FMath::Tan(FMath::DegreesToRadians(LightComp->OuterConeAngle)) * ConeLine.Size();
bool bInsideCone = FMath::GetDistanceWithinConeSegment(myCoordinates, LightComp->GetOwner()->GetActorLocation(), ConeLine, 0, RadiusAtEnd, Exposition);

p.s. you should probably also consider using the actual component location/rotation instead of that of the owner Actor. Depending on the component hierarchy they may be different.

Thank you very much! Looks like I can’t read parameters definitions properly.
Everything is working now.
Thanks for the tips also, I had no idea the transform of the components were accessible.