• RuntimesUnity
  • Is there any way to ray casting in unity? touch interactive

HI. I'm trying to make a game with spine. but I don't know how to interactive things in spine

for example.
if mouse down on character's arm. then it's arm will follow my mouse position.
or
if mouse down on cloth, then the cloth will follow my mouse position.

I searched for days. but I can't find some.

Related Discussions
...

To achieve interactive elements in Unity using Spine, you can use Unity's raycasting capabilities to detect mouse interactions with your Spine character. For example, you can use Physics2D.Raycast to detect clicks on specific parts of your character, such as the arm or cloth. Once you detect a click, you can use the BoneFollower component to make the bone follow the mouse position. This involves setting up a BoneFollower on the GameObject that represents the part of the character you want to interact with, and then updating the bone's position based on the mouse position during the drag operation.

For more detailed implementation, you can refer to the BoneFollower component documentation: BoneFollower.

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

    can physics2d raycast will detect mesh ? or specific parts of spine?
    is there any collider or something implemented in there?

    Spinebot

    can physics2d raycast will detect mesh ? or specific parts of spine?
    is there any collider or something implemented in there?

    can you give me some examples for this?

    @changil The spine-unity runtime uses standard Unity components like a MeshRenderer to render a normal (procedurally generated) Unity Mesh. Spine covers only animation and mesh generation, collision detection and raycast intersection is still done via Unity's components.

    You could e.g. create a GameObject with a BoneFollower component and let it follow e.g. your upper-arm bone, then attach a BoxCollider or BoxCollider2D component as you would with normal Unity objects. Then collision and raycasts can interact with the box collider as ususal.

    If you want to use drag-and-drop to remove a cloth-item from the character skeleton to undress it and drag it e.g. into an inventory slot, I would recommend against moving any bone around. You would normally generate a new independet GameObject for the dragged cloth item. This could be either a Unity Sprite (a static image) or a new SkeletonRenderer GameObject with just the respective cloth-item skin active.