Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
            //}
        }