Jump to content

Jetpack Particle to Follow Avatar


michagoose
 Share

Recommended Posts

Hello! 

I've been dabbling in Babylon for a month or so now, and things are going well, but I'm getting caught up on this one problem:

I have several avatars in a row. They all have jetpacks, but there should only be one active any time. I've parented the emitter fountain objects to each of the avatar's hip bones and then offset it so that it's behind the avatar roughly in the location of the jetpack on the mesh. It works fine for the avatar at (0,0) but the fountain doesn't seem to move when i translate each of the avatars into their final positions Isn't that what parenting does? It does rotate gently as my avatar moves in it's idle animation, so I know it's attached. Even if I don't set the position of the fountain, it still doesn't move along the x axis when my avatar does. 

I've tried to approximate my scene using the playground here: https://www.babylonjs-playground.com/#424Q55#2

The Rabbits are structurally a bit different from my meshes in terms of skeleton and my avatar's have no submeshes like the Rabbit does. You can see that although there are 6 different emitters, they're all at the same place. I've turned on the visiblity of the fountain so you can see it if you rotate the scene behind the avatars.

A related problem I'm having (even when the avatar is at 0,0) is that when i rotate an avatar and animate it, the emitter follows the path of the avatar as if it wasn't rotate at all.

Am I parenting incorrectly or missing a step? I know setting position changes the world position, but it seems like with the parenting, the x position should still change as the parent does.

Thanks for any help you can provide!

Link to comment
Share on other sites

Hiya M, welcome to the forum.

12 minutes ago, michagoose said:

I've parented the emitter fountain objects to each of the avatar's hip bones

That might be the problem.  Bones, as in skeleton/armature bones?

Parent the emitters to the root or top-most mesh/transformNode... of the avatar (if possible).

I'm no pro at these things, but try that.  You'll still need to position-offset the (invisible) emitters so that they are at the avatar's hip-level and width.

Once the emitters (fountains) are positioned and rotated as-wanted, you might wish to do some emitter.bakeCurrentTransformIntoVertices() calls on them.  Notice that AFTER you do that, each emitter's .position and .rotation will be set to 0,0,0, yet the mesh didn't move at all.  Sometimes a handy thing.

Keep us posted on things learned, if anything.  thx.

Link to comment
Share on other sites

I tried parenting it at the top most mesh previously, but I tried it again just now with the addition of bakeCurrentTransformIntoVertices() .

In the playground it worked mostly (perhaps some weird rotation of the particles but that's easily fixed): https://www.babylonjs-playground.com/#424Q55#3

But when I try it in my project, it doesn't have the same effect. (see the image below) Parenting to the top most mesh helps with the x transform position, but now the particle system doesn't move at all when the avatar does. (I should note, that unlike in the original playground I posted - in my scene when the system is parented to a bone, the particle system does move as the avatar animates, only the x transform is wrong) 

The code is basically the same minus a few unrelated elements that I removed in the playground and the avatars themselves. My avatars do have a submesh. I was wrong about that earlier, but the skeleton isn't nested inside it like the Rabbit, if that makes sense.

My avatars are animating with a animation made in blender, instead of simply moving the x position like I'm doing in the playground. Could that be what's causing the difference in behavior? My best guess is that when the avatars where created they didn't animate the entirety of the avatar, just the innards. But the animator is long gone, so I have to work with what I have. 

 

flyaway.png

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