Jump to content

Problem with animation action


danksch
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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!

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