• RuntimesUnity
  • Can the new physics simulation be widely used in Unity games?

Does the unity runtime of spine 4.2 support applying force to a specified bone? I use physical simulation to create the shaking of branches. Can the branches be collided to cause the branches and their leaves to shake naturally? The grass on the ground was also shaken by the collision. Does this effect consume a lot of CPU performance?

Does unity runtime have a sleep function for physics? For example, when the player is close, it will start simulating physics, and when the player is far away, it will play the animation.

    Related Discussions
    ...
    • Editado

    suanLoBeach Unfortunately, Harald, who is responsible for spine-unity, is on vacation and won't be back until Monday. I am sure he will respond to you as soon as he returns, so I would appreciate it if you could wait until then.

      @suanLoBeach Thanks for your wishes, sorry for the late reply! Actually it was a national holiday, but still nice having an additional day off 🙂.

      suanLoBeach Does the unity runtime of spine 4.2 support applying force to a specified bone?

      While you can't directly apply a force to a Bone object like e.g. calling a method bone.applyForce(forceVector), you can indirectly achieve similar results. You could use a SkeletonUtilityBone hierarchy with some bones set to Mode Override to let a Bone follow a Unity Transform with a Rigidbody (or Rigidbody2D) and a Collider.

      You might want to check out the following documentation section on how to create a hinge chain physics setup with spine-unity:
      https://esotericsoftware.com/spine-unity#Create-2D-and-3D-Hinge-Chains-for-Physics

      Note that the above was already possible before 4.2-beta PhysicsConstraints were introduced. Nevertheless you could e.g. drive one Bone via a SkeletonUtilityBone with a Unity Rigidbody attached, and let Spine 4.2-beta PhysicsConstraint perform any dependent (e.g. child bone) movement for you.

      suanLoBeach Can the branches be collided to cause the branches and their leaves to shake naturally?

      There is no built-in collision support available yet in Spine 4.2-beta physics. Apart from that, I doubt that collision would look good when applied to branches and leaves of trees. Nevertheless, you could use the SkeletonUtilityBone setup described above if you need collisions.

      Does this effect consume a lot of CPU performance?

      PhysicsConstraint is not very costly performance-wise. It is roughly comparable to other Spine constraints.

      Does unity runtime have a sleep function for physics?

      There is no such feature built-in, as Spine physics are not a collision-driven simulation. You could theoretically derive your own subclass from SkeletonAnimation, override UpdateWorldTransform() and only call skeleton.UpdateWorldTransform(Update) when necessary. However, it should not really be necessary as the Physics constraint would likely not be a bottleneck.

      If you want to implement branches shaking with collision however, it might be easiest to use the SkeletonUtilityBone or hinge-chain setup described in the top paragraph.