Adding Inner Trigger to our turret .

Suleiman Abdullah
3 min readApr 5, 2024

Objective: Adding Inner Trigger to our turret.

Before doing this ,I update the angle using trigonometry formula ,last time we define angle using dot product. Those below are property written in short form. why we divide fov (field of view) because we only need half angle to find the value of p(transform .forward) ,go to my last article you will understand.

Lets Draw our visual first.

First lets rename radius to outer Radius and create another radius called inner Radius.

Now lets rename our vLeft and vRight to vLeftOuter and vRighOuter.

We do this because we want to draw Inner Radius, lets duplicate those vLeftOuter and vRightOuter and change Outer to Inner the duplicated line.

Put VleftOuter on top of the handles code since we need to access it into the Handles, then we need to add change handles to Hanles.DrawWireArc .This method pass center point, normal, start point, Endpoint and radius.

We need to draw line starting from Inner vector ,and do top lines by add top with inner vector and end by plus top with outerRadius.

Note: To use this logic we need to change from DrawRay to DrawLine.

To draw vertical line we need to start from the bottom using inner vector which is vLeftInner and vRightInner. We end with top plus vLeft and vRight .

Final We need to draw a Inner arc we duplicate our DrawWireArc but we start in the vLeftInner in botth , last we use InnerRadius as radius parameter.

Calculation

We go to Contain method when we check if flatDistance is greater than OuterRadius we add OR condition to check if flatDistace is less than InnerRadius.

This is how to make Inner Radius in Wedge Trigger.

See you in the next one.

--

--

Suleiman Abdullah

Self taught Unity Developer, who is passion about making games ,and he loves Math For Game Development