I tried to look around a bit, but I didn’t find exactly what I was looking for…
I’m new to Unity, so I’m basically just playing around with stuff, trying to understand how things work. I got a bit stuck on animating parts of a character by using the code.
how should I access various bones from the script? I attached my script to the player object, and I think the right hierarchy to access the neck transform should be Armature.upper_spine.neck.transform, by how my gameobject looks like, but it’s not working at all.
Instead it works [sort of] fine with GameObject.Find(“neck”) or by creating a script explicitly for the neck and attaching it to the “neck” object.
Is there a more correct way to access various bones in the hierarchy?
in both the ways described above, I tried to reproduce what I already did with the whole mesh, that is rotating while a key is pressed (w\ the Q and E keys). If I do that directly on the gameObject (transform.Rotate), the whole character keeps rotating while the key is pressed, but on the neck it just rotates by the angle I specify as a parameter and stops there.
This happens with both methods described in point 1) to access a bone (neck).
In addition to this, the neck seems to work only if I call the methods from LateUpdate, while the entire character works in the Update, too. (I know I should use coroutines, still working on that).
Why is this happening? Do objects and bones simply work differently?
I found a good piece of code online that helped me a bit (saving the rotation in a variable, then looping the new rotation value in a coroutine), but I still don’t understand the reason for this difference.
Thanks in advance!