• Unity
  • How to control visibility by BoneFollower or sth else?

  • Изменено
Related Discussions
...

Hi, I want to combine some prefabs to the bone in unity,such as particle or unity mesh.

But if I want them show in only a little frames to adapt the animation,the BoneFollower can't make it.

It can only control the position and rotation,but can't control the visibility or scale.

Is there any way to satisfy my needs without write extra script?

ttt1088 написал

It can only control the position and rotation,but can't control the visibility or scale.

Please note that BoneFollower provides the property Follow Local Scale.
I'm afraid there is no built-in script provided yet that applies the visibility of a bone (bone.active for skin-bones) or the enabled-state of certain attachments at slots to your target GameObject, sorry.

Harald написал
ttt1088 написал

It can only control the position and rotation,but can't control the visibility or scale.

Please note that BoneFollower provides the property Follow Local Scale.
I'm afraid there is no built-in script provided yet that applies the visibility of a bone (bone.active for skin-bones) or the enabled-state of certain attachments at slots to your target GameObject, sorry.

Sorry,I forgot to set particle scaling mode to "Hierarchy",it makes me think the "Follow Local Scale" not working.

As an additional question,is there any perfomance issue if I use scale 0 to control the visibility of BoneFollower?Is this a recommended workflow?

ttt1088 написал

As an additional question,is there any perfomance issue if I use scale 0 to control the visibility of BoneFollower?Is this a recommended workflow?

This has some drawbacks, as it will:

  1. Still have the animation being calculated.

  2. When changing from scale 1 to scale 0 and back, you need the scale keyframes very close together, otherwise you will see a gradual linear shrinking/growing animation (even if it's very brief).

The most likely best way would be to just write a simple script that queries the Attachment state at a Slot (or bone.enabled if you really need to follow bone visibility) and then sets the target GameObject's enabled state accordingly. That will only take a few lines of code.

Harald написал
ttt1088 написал

As an additional question,is there any perfomance issue if I use scale 0 to control the visibility of BoneFollower?Is this a recommended workflow?

This has some drawbacks, as it will:

  1. Still have the animation being calculated.

  2. When changing from scale 1 to scale 0 and back, you need the scale keyframes very close together, otherwise you will see a gradual linear shrinking/growing animation (even if it's very brief).

The most likely best way would be to just write a simple script that queries the Attachment state at a Slot (or bone.enabled if you really need to follow bone visibility) and then sets the target GameObject's enabled state accordingly. That will only take a few lines of code.

I get it.Thanks for your help!

You're welcome! 🙂