Hello to all,
I hope someone can help me …
Basically I have a character that I anim via Animator and several “separate” pieces of clothing that were made with the same rigging.
What I’m trying to do is make the clothes move at the same time as the character so I created a script that mimics the position of each the character bones on the clothes bon.
The problem is that although it works there is a slight flicker (they are not perfectly synchronized , perhaps due to the slowness of the cycle).
Anyone have any ideas on how to synchronize the clothing with the character or how to improve the script?
Thanks in advance.
This is the script:
using UnityEngine;
public class BonesSync : MonoBehaviour
{
[SerializeField] GameObject characterObj;
Transform[] characterBones;
Transform[] thisBones;
SkinnedMeshRenderer dressRender;
private void Start()
{
characterBones = characterObj.GetComponentInChildren<SkinnedMeshRenderer>().bones;
dressRender = this.GetComponentInChildren<SkinnedMeshRenderer>();
thisBones = dressRender.bones;
}
void LateUpdate()
{
for (int i = 0; i < thisBones.Length; i++)
{
thisBones[i].eulerAngles = characterBones[i].eulerAngles;
thisBones[i].position = characterBones[i].position;
}
}
}