Community Tutorial: How to Perform Cone-Shaped Traces in Unreal Engine

Learn how to perform flexible and performant cone-shaped traces in Unreal Engine 5!

https://dev.epicgames.com/community/learning/tutorials/pBv0/how-to-perform-cone-shaped-traces-in-unreal-engine

Thank you so much. This really helps me a lote.

1 Like

Thank you so much !
This is exactly what I was desperately looking for.

In my case it was for a horizontal sweep attack for a topdown game (vampire survivor but 3d), and the area of effect can scale with stats, so it is difficult to handle with collision box.
One minor change that I have made is adding a new boolean parameter bCanHitBeyondCone
And if it is checked, we can hit beyond the cone distance (LengthAtAngle)

		    if (!bCanHitBeyondCone)
		    {
		        const double Distance = (HitResult.ImpactPoint - Start).Length();
		        // Hypotenuse = adjacent / cos(theta)
		        const double LengthAtAngle = ConeHeight / cos(DeltaAngle);
	 
		        // Hit is beyond the cone. This can happen because we sweep with spheres, which results in a cap at the end of the sweep.
		        if (Distance > LengthAtAngle)
		        {
		            continue;
		        }
		    }

It is because my case/attack is more a half-circle than a true cone.

1 Like