26 lines
1.1 KiB
C#

using UnityEngine;
namespace Passer.CreatureControl {
public class Creature : MonoBehaviour {
/// <summary>The target bones rig</summary>
/// The target bones rig contain the target pose of the creature
/// The creature movements will try to move the creature such that the target pose is reached
/// as closely as possible
public TargetRig targetRig;
/// <summary>Match the target rig transform to the humanoid transform</summary>
public static void CheckTargetRig(Creature creature, string targetRigResourceName) {
if (creature.targetRig == null) {
GameObject targetsRigPrefab = Resources.Load<GameObject>(targetRigResourceName);
GameObject targetRig = Instantiate(targetsRigPrefab);
targetRig.name = "Target Rig";
targetRig.transform.SetPositionAndRotation(creature.transform.position, creature.transform.rotation);
targetRig.transform.SetParent(creature.transform);
creature.targetRig = targetRig.GetComponent<TargetRig>();
}
}
}
}