Author Topic: Trigger weirdness  (Read 942 times)

I'm trying to create a trigger, but it seems that the more diagonally I rotate a trigger, the less accurate it is.
Here is the code I'm using to create the trigger:

Code: [Select]
%trigger = new Trigger()
{
datablock = BeamTriggerData;
rotation = %rotation;
position = %pos;
polyhedron = "0 0 0 1 0 0 0 -1 0 0 0 1"; // This determines the shape of the trigger.
client = %client;
};
%trigger.schedule(3000, setScale, 0.1 SPC 0.1 SPC %triggerlength);

Now, for instance, if I was to create a trigger in this way, with a %triggerlength of 10, with the rotation
Code: [Select]
-0.577352 -0.57735 0.57735 120(Note that this rotation is pointing directly south)
The trigger is fine. It detects everything that comes within it's bounds perfectly fine.

Now, give it the rotation
Code: [Select]
-0.707108 0.707105 0 90(Note that this rotation is pointing directly south west)
And the trigger starts to produce very strange results. It's not accurate, as in, it will trigger when you are too far away from the trigger. It also produces very strange artifacts, for example, when you trigger the trigger, you have to backtrack significantly further than you walked into the trigger to leave the trigger.

Any clarification on this would be appreciated.

i might be wrong but in my experience with collision, the collision box will never rotate, it will just take on the maximum bounds of the shape. so as you rotate the trigger more, the bounding box will become larger on the x and y axis to the maximum x and y coordinates



look at yellow and green dotted lines as the bounds, while the solid black line is the trigger
« Last Edit: June 03, 2017, 02:40:47 AM by PhantOS »



Yup lmao.

Well, I guess the question to ask now is how do I create an accurate box trigger that goes from point A to point B without just creating a massive box encompassing the two

i dont think triggers are supposed to rotate, youll have to do those checks within onTickTrigger

you probably want to use the large trigger, check if the subject is in the area you want, otherwise discard the input

would need to trigger on in the zone, instead of just entering the zone

i dont think triggers are supposed to rotate, youll have to do those checks within onTickTrigger
you probably want to use the large trigger, check if the subject is in the area you want, otherwise discard the input

Would the best way to do this be firing a raycast from %pos along the vector of rotation to see if it finds the player?

im curious- what are you trying to do here? are you making like a 1 dimensional beam or are you trying to specify a polygonal zone and check if players enter it? for the former, firing a single raycast line would suffice, or if you're checking for a larger range, maybe a contaner box. for a zone you could also use a container box and simply rotate all its points around a given vertex

You could try applying the rotation to the polyhedron parameter instead of setting the transform. It's fairly simple, 1 offset vector then 3 orthogonal vectors to define a box from it.
For example, this would make a 1x1x1 trigger centered on it's position: -0.5 -0.5 -0.5 1 0 0 0 1 0 0 0 1
This should make the trigger rotated 45 deg on the Z axis, if it works: -0.707 0 -0.5 0.707 0.707 0 -0.707 0.707 0 0 0 1
« Last Edit: June 03, 2017, 04:08:01 AM by Zeblote »

im curious- what are you trying to do here? are you making like a 1 dimensional beam or are you trying to specify a polygonal zone and check if players enter it? for the former, firing a single raycast line would suffice, or if you're checking for a larger range, maybe a contaner box. for a zone you could also use a container box and simply rotate all its points around a given vertex

One dimensional beam, yeah. Needed it for this, I did eventually settled for using raycasts to determine if the triggerer is in the correct place.



It would have to be sitting on-top of the origin instead of centered on it because the way I'm doing it is rotating the trigger to the direction of the beam, and then scaling it to the length of the beam.

Thanks for your advice, I'll try and see if I can wrap my head around this.