Game Development Community

How do I make a circular trigger?

by Andreas Petrov · in Technical Issues · 09/29/2007 (1:05 pm) · 5 replies

I need something with the functionality of the Trigger class, but with a radius as variable instead of polyhedron. Is this possible, or should I just make a polyhedron with enough sides to resemble a circle?

#1
09/29/2007 (3:21 pm)
It would probably be simpler to make a box shaped trigger which is large enough to encompass the circular area you wish to define (ie the dimensions match the diameter). And then do a radius check on the objects which intersect with that trigger.

Gabriel
#2
09/29/2007 (4:38 pm)
Thats a great idea indeed! Thanks.
#3
09/29/2007 (11:39 pm)
.
#4
09/30/2007 (5:11 pm)
@Berserk: Seems like a good idea, but that would kinda remove the whole onEnter onLeave functionality of the trigger wouldnt it?

Now I seem to have a problem creating the proper polyhedron coordinates based on a radius.
I tried making a cube by using the method found here:

www.csee.umbc.edu/~squire/reference/polyhedra.shtml#cube

I made it into this hillariously ugly piece of work:

function CommandBeaconTrigger::createPolyhedron(%radius)
{

   %v0 = " 0.816 0.000 0.577"; 
   %v0 = VectorScale( %v0 , %radius );
   %v1 = " 0.000 0.816 0.577"; 
   %v1 = VectorScale( %v1 , %radius );
   %v2 = "-0.816 0.000 0.577"; 
   %v2 = VectorScale( %v2 , %radius );
   %v3 = "-0.000 0.816 0.577";
   %v3 = VectorScale( %v3 , %radius );
   %v4 = "0.816 0.000 -0.577"; 
   %v4 = VectorScale( %v4 , %radius );
   %v5 = "0.000 0.816 -0.577";
   %v5 = VectorScale( %v5 , %radius );
   %v6 = "-0.816 0.000 -0.577"; 
   %v6 = VectorScale( %v6 , %radius );
   %v7 = "-0.000 -0.816 -0.577"; 
   %v7 = VectorScale( %v7 , %radius );
   
   %poly1 = %v0 SPC %v1 SPC %v2 SPC %v3;
   %poly2 = %v4 SPC %v5 SPC %v6 SPC %v7;
   %poly3 = %v0 SPC %v1 SPC %v5 SPC %v4;
   %poly4 = %v1 SPC %v2 SPC %v6 SPC %v5;
   %poly5 = %v2 SPC %v3 SPC %v7 SPC %v6;
   %poly6 = %v3 SPC %v0 SPC %v4 SPC %v7;
   
   return %poly1 SPC %poly2 SPC %poly3 SPC %poly4 SPC %poly5 SPC %poly6;
}

This didnt create the cube trigger I wanted however, just some twisted two dimensional stuff.
#5
09/30/2007 (5:17 pm)
If you create a trigger in the editor, the default shape is a cube. You can see how its form there, or use that for you poly data. You can also scale the cube to your requirements (and rotate I believe).

Gabriel