Jump to content

[SOLVED] - The box for a trigger zone


MackeyK24
 Share

Recommended Posts

How should i create the box mesh to use as a trigger zone... I really want a non-visible box area to walk thru and trigger and event.

I get that i can use the action manager and or just check intersects with in update loop. But i can trying to add support for trigger volumes to my BabylonsJS Toolkit and i am creating the box using the babylon.entities api in C#.

So i guess what i an asking is 'HOW MUCH' of a regular cube mesh do i need to create for it to be a non-visible at runtime area that still has some kind of geometry that defines that actual area of the box that 'lives' so the mesh.intersect api works.

Right now i am making just a normal mesh box and if it is a 'trigger a volume' i just set set the babylonMesh.visibility = 0 and babylonMesh.isVisible = false then just DONT create the mesh materials for it by skipping the if (render != null) section that does all that good stuff.

Now is that how i should create an area box? Just make a normal box and set its visible = false... ?

Or What ???

Thanks for the info :)

 

Link to comment
Share on other sites

This SEEMS to work too... and allows interaction with the bounding box and debug labels in debug mode... Does anyone see a problem with not really making a trigger area INVISIBLE but rather a REALLY LOW visibility like so:

if (isTriggerArea == true) {
  babylonMesh.isVisible = true;
  babylonMesh.visibility = 0.000001f;
  babylonMesh.checkCollisions = false;
}

 

Link to comment
Share on other sites

Well if isVisible = false OR visibility = 0

Then nothing is shown in Debug layer like labels and bounding boxes.

I tweaked out the Unity export to support "IsTrigger" on the collider... So if "IsTrigger" = true  i don't create the materials from the renderer ... just geometry... then

set visibility = 0.000001 so you can't see it... but the "Volume" or Bounding Box of the "Trigger Area" can be seen and interacted with in the debug layer...

Unless you can change the debug layer to still include geometry with visible = false... THAT WOULD BE GREAT... then no need to "KLUDGE" with visibility = 0.00001

Pretty Please :)

 

Link to comment
Share on other sites

You could also just code your own areaTrigger function :)

no need for boxes or any other geometry, all you really need is the xyz positions, 
I assume you know where your player is,
and where you want the triggerArea,

With that information, you can create two arrays, a min xyz and a max xyz, thus making a virtual box, the triggerArea,
which you can then check the player's position against once in a while, 1-2 times a second should be enough.

Clean, simple and fast :)


Made an example PG, open your console (ctrl + shift + i for chrome, f12 for IE edge), 

the trigger is fired once each time the sphere enters the trigger area, everything should be rather self-explaining, e.g. setting the "runOnlyOnce" variable in a trigger to true will disable the trigger after it have run one time, etc.

http://www.babylonjs-playground.com/#18CGS5#3

Link to comment
Share on other sites

Coding trigger area won't work... I am creating a BabylonJS IDE Toolkit... The whole point is create your scene (even the whole game) in the Game editor (Unity with BabylonJS Toolkit)... So i will be using the "Trigger Volumes" from unity.. which is really a box with no mesh renderer and collisions set OFF so can pass thru... Then i just use mesh.intersectMesh on the trigger volume to check if my player passed thru trigger area... THIS WORKS GREAT... its just that in the debug layer, since the mesh is TOTALLY invisible... its DOES NOT get represented in the debug layer (No bounding box or clickable labels for the trigger area). But if i make the visibility = 0.00001 you CANT see it ... BUT it sill has a "representation" in debug  layer... I hope David can change debug layer to include invisible meshes ... Then i won't have to KLUDGE at all :)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...