iodizer Posted March 25, 2016 Share Posted March 25, 2016 Hi, could anyone provide me with a standard example for an ExecuteCodeAction. I haven't been able to find any examples. I can verify that the code below doesn't work Part of my problem is that I don't understand what the conditional at the end is for... Thanks! ''' var makeClickResponse = function(mesh){ mesh.actionManager = new BABYLON.ActionManager(scene); mesh.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLeftPickTrigger, function(){console.log("it works! "+mesh.name)}, true)); } ''' Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 26, 2016 Share Posted March 26, 2016 Hi Iodizer! Did you try using our playground searcher for the term executeCodeAction? http://doc.babylonjs.com/playground?q=ExecuteCodeAction&page=1&max=2500&bf=all This one seems like a pretty decent demo. Hope this helps. Quote Link to comment Share on other sites More sharing options...
Temechon Posted March 27, 2016 Share Posted March 27, 2016 Extracted from http://pixelcodr.com/tutos/plane/plane.html var onpickAction = new BABYLON.ExecuteCodeAction( BABYLON.ActionManager.OnPickTrigger, function(evt) { if (evt.meshUnderPointer) { // Find the clicked mesh var meshClicked = evt.meshUnderPointer; // Detroy it ! meshClicked.dispose(); // Reduce the number of ammo by one ship.ammo -= 1; // Update the ammo label ship.sendEvent(); } }, condition); b.actionManager.registerAction(onpickAction); Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 27, 2016 Share Posted March 27, 2016 Other good ideas to find examples: go to http://doc.babylonjs.com/playground?q=ExecuteCodeAction Wingnut 1 Quote Link to comment Share on other sites More sharing options...
iodizer Posted March 28, 2016 Author Share Posted March 28, 2016 Thanks a lot guys. I had no idea about the search the playground feature, that is excellent. The condition is apparently optional. For those interested the desired function ended up looking like this var makeClickResponse = function(mesh){ mesh.actionManager = new BABYLON.ActionManager(scene); mesh.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLeftPickTrigger, function(unit_mesh){ console.log("it works! " + unit_mesh.meshUnderPointer.name)}) ); } JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.