• Runtimes
  • Having bones follow object in Unity

Hey guys,
I am trying to figure out how to manipulate bones during run time in Unity. I am going to have a character animation that is holding a gun. I would like to make it so the gun will follow an object such as my mouse cursor. I have had a hard time finding a lot of information on how to accomplish this. The documentation seems to be in Java and I have a hard time translating it all into C# for Unity. Also I am using the 2DTK.

Could someone please help me with an example of where to even get started? I am basically starting from ground zero in regards to learning the Spine runtime stuff inside of Unity.

Thanks so much.

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

https://github.com/EsotericSoftware/spi ... l.java#L66

This code applies an animation, then adjusts bone rotations using the mouse position and atan2. You don't need to port this to directly to C#, but it shows how to do it. You can subclass SkeletonComponent or SkeletonAnimation and do your manipulation.

Thanks for the reply Nate.
That code should help me be able to figure it out. What I wonder though is how people are able to look at that and then figure out the syntax that would be needed for C# for example? Is it just trial and error or is there documentation for the runtime API in C# somewhere?

Is the "Render" method specific to use with Spine? Or would that be put into the "Update" method in Unity?

C# and Java have almost identical syntax, at least Java to C# is pretty easy since Java has less fancy language features. First read through the spine-unity code to see how it works. There are really only about 2 classes. Looking at the spine-csharp code would be good too.

Yes, the Update method is likely what you want to use.