Пример #1
0
        public AISteerFabulaClip(JSONNode json, TimelineAsset p_timeline, PlayableDirector p_director)
            : base(json, p_timeline, p_director)
        {
            var TC = agent.GetComponent <DynoBehavior_TimelineControl>();

            TC.InitiateExternally();

            ending_location = GameObject.Find(json["end_pos_name"].Value);

            ClipInfo CI = new ClipInfo(p_director, start, duration, Name);

            // Here, we need to indicate that this is a master or not.
            CI.SteerClip(agent, starting_location.transform.position, ending_location.transform.position, false, true, true);

            // number of segs should based on total path / slow radius
            var lastPosition = starting_location.transform.position;
            var distance     = ending_location.transform.position - lastPosition;

            //var KB = agent.GetComponent<Kinematic>();
            var SP = agent.GetComponent <SteeringParams>();

            var slowRadius = agent.GetComponent <DynoBehavior_TimelineControl>().slowRadius;
            int numSegs    = (int)Mathf.Ceil(distance.magnitude / slowRadius);
            var eachSeg    = duration / numSegs;

            var directionSeg = distance / numSegs;

            for (int n = 0; n < numSegs; n++)
            {
                var p = SimulateSteering(starting_location.transform.position, ending_location.transform.position, SP, n * eachSeg);

                //var p = lastPosition + directionSeg;

                if (n == 0)
                {
                    lastPosition = p;
                    continue;
                }
                CI = new ClipInfo(p_director, start + n * eachSeg, eachSeg, Name + n.ToString());

                CI.SteerClip(agent, lastPosition, ending_location.transform.position, true, true, false);
                lastPosition = p;
            }
        }
Пример #2
0
        public DroneSteerFabulaClip(JSONNode json, TimelineAsset p_timeline, PlayableDirector p_director)
            : base(json, p_timeline, p_director)
        {
            ending_location = GameObject.Find(json["end_pos_name"].Value);

            // create Steer for each edge in path
            int numSegs      = 4;
            var eachSeg      = duration / numSegs;
            var lastPosition = starting_location.transform.position;
            var directionSeg = (ending_location.transform.position - lastPosition) / numSegs;


            // test
            ClipInfo CI = new ClipInfo(p_director, start, duration, Name);

            CI.SteerClip(agent, starting_location.transform.position, ending_location.transform.position, true, true, true);
            // for each segment
            //for (int n = 0;  n < numSegs; n++)
            //{
            //    ClipInfo CI = new ClipInfo(p_director, start + n * eachSeg, eachSeg, Name);
            //    var p = lastPosition + directionSeg;
            //    // for test:
            //    //GameObject intermed = new GameObject();
            //    //intermed.name = n.ToString();
            //    //intermed.transform.position = p;
            //    if (n == 0)
            //    {
            //        CI.SteerClip(agent, lastPosition, p, true, false);
            //    }
            //    else if (n == numSegs - 1)
            //    {
            //        CI.SteerClip(agent, lastPosition, ending_location.transform.position, false, true);
            //    }
            //    else
            //    {
            //        CI.SteerClip(agent, lastPosition, p, false, false);
            //    }
            //    lastPosition = p;
            //}
        }
Пример #3
0
        public SteerFabulaClip(JSONNode json, TimelineAsset p_timeline, PlayableDirector p_director)
            : base(json, p_timeline, p_director)
        {
            ending_location = GameObject.Find(json["end_pos_name"].Value);

            // Quantize to find start and finish nodes
            startNode = QuantizeLocalize.Quantize(starting_location.transform.position, TrackAttributes.TG);
            goalNode  = QuantizeLocalize.Quantize(ending_location.transform.position, TrackAttributes.TG);

            // Calculate path
            Path = PathFind.Dijkstra(TrackAttributes.TG, startNode, goalNode);

            // create Lerp for each edge in path
            var eachSeg  = duration / Path.Count;
            int n        = 0;
            var lastNode = startNode;

            foreach (Node p in Path)
            {
                ClipInfo CI = new ClipInfo(p_director, start + n * eachSeg, eachSeg, Name);

                CI.SimpleLerpClip(agent, lastNode.transform, p.transform);
                lastNode = p;
                n++;
            }

            // run animation across whole thing if not null
            if (json["animation_name"] != null)
            {
                control_track_clip             = ctrack.CreateDefaultClip();
                control_track_clip.start       = start + 0.06f;
                control_track_clip.duration    = duration - 0.06f;
                control_track_clip.displayName = Name;
                controlAnim = control_track_clip.asset as ControlPlayableAsset;
                AnimateBind(controlAnim, animTimelineObject);
            }
        }