Create Radial Trigger.

Suleiman Abdullah
2 min readFeb 26, 2024

--

Objective: Create Radial Trigger.

In the first step I will create two game object ,renaming them as player and Explosion Trigger.

Create a script called Explosion Trigger and attach it to the Explosion Trigger game Object. Create two variable a float called radius initialize it to 1 and Transform called target.

I will define origin position and player position inside the OnDrawGizmos ,then I will calculate displacement between this two objects.

Note: You don't need OnDrawGizmos to create this feature ,OnDrawGizmos is only for able to run this code without play mode and visual .

Create a bool variable called isInside , then assign condition to be true which if displacement is less than radius ,this bool will be true. I will set the color of Gizmos according to this bool if true the color will be green and red if the condition is false .Last I will draw the sphere using gizmos.

Bonus.

This is how to create Radial Trigger.

See in the next one.

--

--

Suleiman Abdullah
Suleiman Abdullah

Written by Suleiman Abdullah

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

No responses yet