Jump to content

Newbie OnPickTrigger Problem


MackeyK24
 Share

Recommended Posts

Hey guys... I never actually used the babylon action manager (or observables) before, i was handling all interactions myself. But i want to setup some kind of metadata so i can configure

mesh actions in the Unity Editor Toolkit. But what i think should is not... This is what i thought is a simple click action

 

// Setup pick action
sphere.actionManager = new BABYLON.ActionManager(scene);
sphere.actionManager.registerAction(new BABYLON.ExecuteCodeAction({ trigger: BABYLON.ActionManager.OnPickTrigger }, function() {
   console.log("Got Pick Action");
}));    

 

But dont get anything if 'Click' on the sphere :(

Please check this playground https://playground.babylonjs.com/#4SH4JZ

 

Link to comment
Share on other sites

You were nearly there, but if you don't supply a parameter with your constructor object, then you need to pass a number (BABYLON.ActionManager.OnPickTrigger is a number) as SinhNQ did.  Here is your PG with the extra property added to trigger options:
https://playground.babylonjs.com/#4SH4JZ#2

You can see here in the super constructor that you need a parameter, even if it's empty:
https://github.com/BabylonJS/Babylon.js/blob/master/src/Actions/babylon.action.ts#L37

Link to comment
Share on other sites

One more question... i assumed @davrous was using a trigger action on the circle mesh in the mansion. His quote:

 

Quote

When looking at the circle mesh on top of the door of the mansion, the gaze cursor will change from white to blue and will become bigger. This is to indicate to the user he can launch an action associated to this mesh. To trigger it, simply press the A button of the gamepad while looking at it.

 

Well i tried to setup a mesh and change the material with the onpicktrigger... it does work from the mouse click... but in VR mode it does not....

 

What is the trigger you are using to trigger the ghost in the window that works with gamepad A button ???

 

UPDATE

I think OnPickUpTrigger works with Mouse Click and Gamepad A button when no controller... Is That Right ???

But not for VR Controller Trigger, how the heck did he set that up ACTION in 3DS Max ???

 

Link to comment
Share on other sites

12 minutes ago, brianzinn said:

It's all done in the .babylon file (50MB+):
https://www.babylonjs.com/Scenes/Mansion/Mansion.babylon
That file crashed my VSCode and took forever to open in Sublime, but I did find some nested actions starting with OnLeftPickTrigger - does that work?  Find the action you are after and then you need to generate that.

That did it... OnLeftPickTrigger works with Mouse Click, Gamepad A Button And VR Pointer Click Or Trigger :)

Thanks @brianzinn ...

Wait til you guys  @davrous and @Deltakosh see the support i added to the toolkit for WebVR using Dave's VRExperienceHelper in my SceneManager

Things Like:

Controller Prefabs... Now you can use a fully scripted up with nested hierarchy component prefab as your Left and Right VR Controllers...

Floor Mesh Tags... You can now Unity Tag or Babylon Component Tag your floor meshes including terrains... But even though has been an awesome feature for me by itself, i add 

built in Unity Tag called 'Navigation' that the Camera Rig defaults to (you can change or add to it of course) . So you can simple tag your floor meshes with that... But wait... even BETTER...

Navigation Mesh Teleportation... I tied the Built-in Unity Navigation Mesh Generator to TAG itself as 'Navigation'... So instead of using a bunch of arbitrary meshes as floor meshes... You can bake a Navigation mesh with WALKABLE surfaces. The same Nav Mesh you would use for AI to say what is a walkable surface you can now TELEPORT on... It also prevents you from teleporting INSIDE static meshes because the nav mesh has CUTOUTS of NON-WALKABLE areas... You can also now bake the navmesh to use multiple levels in a building... 

You basically DRAPE a navigation mesh over your entire scene defining walkable areas to teleport on... i am using it and works perfect... with the ONE single LOW poly mesh DRAPED accros my secene :)

All this again... with NO lines of code, just configure the camera rig.... Unless you need runtime access to the VRExperienceHelper for more complex intereactions...  You can easily using the internal scene manager VRExperienceHelper exposed as manager.webvr

 

Coming Soon with the 3.3 Beta :)

 

 

 

 

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...