• EditorBugs
  • How to make wind for effecting plants by physics

suanLoBeach You can set the wind value on the physics constraints directly at runtime. If you keyed the wind to the physics constraints, you'd have to change the values after you applied animations.

If you'd rather use an animation, you'd have to create a new animation and timelines, or dig through an existing animation's timelines to find the wind timeline, then you can change the keyed values, add/delete keys, etc. on the wind timeline.

You might want to check out Nate's answer to a question from a user who tried to do something similar with Unity in the past:
https://esotericsoftware.com/forum/d/25363-spine-42-physics-general-questions/12

    Related Discussions
    ...
    5 дней спустя

    Misaki I do not find out the options about physcis on inspector, so How can I set those keys or value ?

    • Misaki ответили на это сообщение.

      suanLoBeach Ah, sorry if my answer was confusing. The Inspector doesn't allow changing constraint properties or adding animation keys. To modify a skeleton's constrained property or add keys, you need to do it in code. This applies not only to physics constraints, but to other elements as well.

      If you just want to change the value of the Wind property directly, you can write code like this:

              SkeletonAnimation skeletonAnimation = GetComponent<SkeletonAnimation>();
              PhysicsConstraint constraint = skeletonAnimation.Skeleton.FindPhysicsConstraint("YourConstraintName");
              constraint.Wind = -2.0f;
        6 дней спустя

        Misaki sorry for the late reply
        As what Nate said, I set wind key to global in a skeleton, but I still need to set them one by one for each skeleton characters.

        I need real-time dynamic wind to achieve the effect of multiple trees being blown by the same gust of wind, so is using loop to set each skeleton wind value with the code you gave me a correctly mothed ? What I wish is that a wind object can affect all spine skeleton instead of setting one by one.

        I want a global physics system in the game world. For example, if I drag and drop a spine skeleton into the game scene, the skeleton will automatically be affected by the wind and gravity in the scene.

        Will the future Unity-runtime have a global automatic physics environment ? Is there such a plan?

        If you load a single skeleton data and share it with multiple skeleton instances, you can change the data (which represents the setup pose) and all instances will be affected. See this image:

        Skeletons loaded from separate data are always separate, changing one doesn't affect the others. We don't have plans to support global physics. Spine's physics are generally just for animation. A full blown physics engine is a lot more complex and has more features, like collision. Games generally use Box2d or another physics library for gameplay and Spine's physics for animation.

        • suanLoBeach ответили на это сообщение.

          Nate Can the spine skeleton use Unity's built-in physics system? Like a ragdoll?

          Nate oh that good, but it could cost more performence, maybe I'll choose spine physics yet

          18 дней спустя

          Misaki Hi again lady
          I'm now using the code you sent me, which uses a loop to iterate through all physics constraints. I'd like to ask, is there an API that can directly set parameter values for all constraints at once? For example, setting the wind value.

          No, but you can easily create your own function.

          • suanLoBeach ответили на это сообщение.

            Nate OK, I'm using loop to set all of bones, it's work fine now.