danksch Posted April 29, 2017 Share Posted April 29, 2017 Hi guys, I'm having a hard time figuring out how to move a given object to the destination of a clicked mesh. Playground link (similar recreated scenario): http://www.babylonjs-playground.com/#2CFAMI#13 As you can see, the first two actions (hovering mouse in/out effect) work fine with every tile, but the animating action seems to always extract the position of the last added tile. I'm suspecting it's because I'm overwriting the tile variable (and thus its position values) or something. I also suspect that using instances for the tiles might be a better option, since in the game they also just use 5 different materials that are loaded before-hand...but first things first. Thanks in advance for taking a look! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 29, 2017 Share Posted April 29, 2017 http://www.babylonjs-playground.com/#2CFAMI#14 Hi danksch... there ya go, that should work. Good test scene, by the way. Look at line 35. See BJS_event (any name will work). It is a special event object that arrives automatically in executeCodeAction functions. If you examine that event object, you'll see... Object { source: Object, pointerX: 494, pointerY: 109, meshUnderPointer: Object, sourceEvent: pointerdown, additionalData: undefined } In line 38, we make tile = the meshUnderPointer. Works gooooood. Hope this helps. Party on! danksch and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
danksch Posted April 29, 2017 Author Share Posted April 29, 2017 Thanks for the fast and productive answer, fixed it right away! Wingnut 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.