(Child) Positions not changing for blendshape guns

Hello,

I am having a fbx mesh made with blender.
It has childs gun meshes with each a blendshape on it. The blendshape changes the position of the guns meshes before shooting.

But when I instantiate the bullets in a loop over the guns (works fine for other cases without blendshapes) they do use use the updated positions after the blendshape changes.

So everything is looking good but the bullets spawn at the “old” position.

Any idea how I can change that? (I hope there is a better way than finding out the correct end positions and store it and use it from script)

Thanks a lot!

I tried with the child’s skinnedmeshrender transform position (does not change and the same for all, seems to be the parents transform position for all) and the child’s SkinnedMeshRenderer.bounds.center, now they at least get different positions but they do not fit, not even close. Any idea?

Standard, all glendshapes 0

All blendshapes to max, all towers (childs of the mesh) instantiate bullets

Hierarchie
9249555--1293177--upload_2023-8-25_12-12-23.png

There are even transform childs for each tower but they are all in the middle of the parent and do not change positions when setting blendshapes…

The colliders of the childs also stay in their original position and rotation, no matter if I set the fbx import to create colliders or if I add them to the prefab hierarchie towers.

Can this be solved or do I need to do without blendshapes?

Thanks for any hints or infos :slight_smile:

Caveat: I only have a little bit of blendshape experience.

Blendshapes appear to only have influence within the scope of the SkinnedMeshRenderer.

This means changes to the blend weights do not in any way affect an armature (bones) that might be used to do boned animation.

I don’t have insight into how the bone → skinned mesh binding “plays nice with” the blendshapes, eg, what happens if you are using bone animation, is blendshape simply added “on top of” that? I have no experience here but I intuit “yes it is blended.”

But in any case, if I understand your use case to be:

  • you have blendshapes AND bones
  • you are adjusting blendshape weights
  • you are finding your bones don’t move.

This seems like a reasonable conclusion to me, even if it is an unfortunate one for the tech path you have chosen.

I hope someone else with more experience mixing Blendshapes with boned animation now chimes in and tells me the parts I am wrong about and corrects me, as well as fills in some of my missing knowledge in Blendshapes!

No Bones. I found a solution, baking the mesh for each child and resetting the collider after setting blendshape values:

                                mov.SkinnedMeshRenderer.SetBlendShapeWeight(i, _blendShapeWeight * 100f);
                                Mesh bakeMesh = new Mesh();
                                mov.SkinnedMeshRenderer.BakeMesh(bakeMesh);

                                var collider = mov.PartGameObject.GetComponent<MeshCollider>();
                                collider.sharedMesh = bakeMesh;

Now colliders match perfectly. And I can spawn my bullets with a given offeset, works like a charm. Thanks for the interest :slight_smile:

1 Like