Buzul
January 30, 2019, 1:44pm
1
Hi everyone…
I’m using a lot of trigger area in my project. I have to create one more, but how can i do that, i haven’t got any idea.
I already created so many trigger area but those areas shapes are like square. But now i need like “L” one.
My question is; how can i combine two diffrent trigger area or how to a trigger area has the special shape like “L”.
thanks in advance…
JohnK
January 30, 2019, 1:49pm
2
A simple PG with one square trigger area would be very helpful for me, and maybe others, to understand what you mean by trigger area.
Buzul
January 30, 2019, 2:03pm
3
You can see in my PG sample
https://www.babylonjs-playground.com/#18CGS5#5
And what i need like a “L” shape
I suppose you could change the code and allow a triggerArea to consist of multiple squares.
like so; (added small gap for illustration)
1 Like
Buzul
January 31, 2019, 5:20am
5
Yes, but in this time character when enter the trigger area triggers will triggerred more thaan one time?
JohnK
January 31, 2019, 12:41pm
6
It seems that by trigger area you mean an area defined by a number of points and then you want to find if a given point is inside the area. This is not really a BabylonJS issue but a mathematical one. One way to do it is described here Point in polygon - Wikipedia .
On looking at your playground code it appears you are using trigger volumes not areas, the above ray casting idea above can be extended as described in https://www.doc.ic.ac.uk/~dfg/graphics/graphics2008/GraphicsLecture04.pdf
In future questions, unless the question is specifically about problems after importing a mesh, it would help us to answer the question if you created simple mesh shapes to illustrate your issue rather than importing from a file. This cuts out irrelevant problems.
Good luck with your project.
1 Like
@Buzul
I didn’t say make two triggers, but allow a single trigger to have multiple areas.
--Now
triggerArea.min: {}
triggerArea.max: {}
--Solution
triggerArea.areas = [];
triggerArea.areas[0] = {min: {}, max: {}}
triggerArea.areas[1] = {min: {}, max: {}}
--And trigger checking code..
for(var i = 0, max = triggerAreas.length; i < max; i++){
var trig = triggerAreas[i];
for(var j = 0; j < trig.areas.length; j++){
var area = trig.areas[j];
// We now have multiple areas for the same trigger.
}
}
1 Like
Buzul
February 1, 2019, 9:18am
8
Thank you i think this will helps me…