using UnityEngine; //!!!!!! //This objective type is still under development //!!!!!! namespace BioIK { //This objective aims to keep particular distances to the defined transform positions. This can be used to integrate //real-time collision avoidance. However, note that collision avoidance is typically a very challenging thing for motion generation, //so please do not expect any wonders or some sort of black magic. It works well for typical scenarios, but it will not solve the world for you. //Note that you should use preferably small weights in order to get good-looking results. Best thing is to play around with it and see what happens. //It is not generally clear how to chose those weights. [AddComponentMenu("")] public class Distance : BioObjective { [SerializeField] private double Radius = 0.1; [SerializeField] private DistancePoint[] Points = new DistancePoint[0]; public override ObjectiveType GetObjectiveType() { return ObjectiveType.Distance; } public override void UpdateData() { if(Segment.Character.Evolution == null) { return; } for(int i=0; i 0) { System.Array.Resize(ref Points, Points.Length-1); } } } [System.Serializable] public class DistancePoint { public Transform Target; public double Radius; public double TPX, TPY, TPZ; public void SetTargetTransform(Transform t) { Target = t; if(Target != null) { SetTargetPoint(Target.position); } } public void SetTargetPoint(Vector3 point) { TPX = point.x; TPY = point.y; TPZ = point.z; } public Vector3 GetTargetPoint() { return new Vector3((float)TPX, (float)TPY, (float)TPZ); } public void SetRadius(double radius) { Radius = radius; } public double GetRadius() { return Radius; } } }