void Start()
 {
     char_RigidBody = GetComponent <Kinematic>();
     goalComponent  = GetComponent <PathGoal>();
     arrive         = GetComponent <DynoArrive_PathFollow>();
     align          = GetComponent <DynoAlign_PathFollow>();
     seek           = GetComponent <DynoSeek_PathFollow>();
 }
        public void OrientAlign()
        {
            // Get the vector to the target to determine target Orientation
            var diff = currentGoal - transform.position;

            diff = diff.normalized;
            float targetOrientation;

            if (diff.magnitude > 0f)
            {
                targetOrientation = Mathf.Atan2(-diff.z, diff.x);
            }
            else
            {
                targetOrientation = KinematicBody.getOrientation();
            }


            // Calculate the needed rotation to reach the target;
            var rotation = targetOrientation - KinematicBody.getOrientation();

            rotation = Kinematic.mapToRange(rotation);
            var rotationSize = Mathf.Abs(rotation);

            if (rotationSize < angularGoalRadius)
            {
                torque             = 0f;
                tiltAmountSideways = 0f;
                return;
            }

            float targetRotation;

            // if we're outside the slow Radius
            if (rotationSize > angularSlowRadius)
            {
                targetRotation = SP.MAXROTATION;
            }
            else
            {
                targetRotation = SP.MAXROTATION * rotationSize / slowRadius;
            }

            // Final target rotation combines speed (already in variable) with rotation direction
            targetRotation = targetRotation * rotation / rotationSize;

            torque = targetRotation - KinematicBody.getRotation();
            torque = torque / alignTime;

            var angularAcceleration = Mathf.Abs(torque);

            if (angularAcceleration > SP.MAXANGULAR)
            {
                torque = torque / angularAcceleration;
                torque = torque * SP.MAXANGULAR;
            }
        }
Example #3
0
        // Use this for initialization
        //void Awake()
        //{
        //    PD = GameObject.FindGameObjectWithTag("FabulaTimeline").GetComponent<PlayableDirector>();
        //    SP = GetComponent<SteeringParams>();
        //    KinematicBody = GetComponent<Kinematic>();
        //    SteerList = new List<List<SteeringPlayable>>();
        //    //SteerList.Add(new List<SteeringPlayable>());
        //    LockedList = new List<bool>();
        //    //LockedList.Add(false);
        //}

        public void InitiateExternally()
        {
            PD            = GameObject.FindGameObjectWithTag("FabulaTimeline").GetComponent <PlayableDirector>();
            SP            = GetComponent <SteeringParams>();
            KinematicBody = GetComponent <Kinematic>();
            SteerList     = new List <List <SteeringPlayable> >();
            //SteerList.Add(new List<SteeringPlayable>());
            LockedList          = new List <bool>();
            initiatedExternally = true;
        }
Example #4
0
        /*END record and write out speed on timer*/

        // Use this for initialization
        void Start()
        {
            char_kinematic = GetComponent <Kinematic>();
            //******
            seek   = GetComponent <KinematicSeek>();
            arrive = GetComponent <KinematicArrive>();
            //******arrive = GetComponent<DynoArrive>();
            align = GetComponent <DynoAlign>();
            //******

            /*record and write out speed on timer*/
            StartTime = Time.time;
            FileName  = "KineTimer.txt";
            System.IO.File.WriteAllText(@"C:\Grad School\AI\A1\" + FileName, "0");
        }
        // Use this for initialization
        //void Awake()
        //{
        //    PD = GameObject.FindGameObjectWithTag("FabulaTimeline").GetComponent<PlayableDirector>();
        //    SP = GetComponent<SteeringParams>();
        //    KinematicBody = GetComponent<Kinematic>();
        //    SteerList = new List<List<SteeringPlayable>>();
        //    //SteerList.Add(new List<SteeringPlayable>());
        //    LockedList = new List<bool>();
        //    //LockedList.Add(false);
        //}

        public void InitiateExternally()
        {
            // Don't do this if it's already been done before.
            if (initiatedExternally)
            {
                return;
            }

            PD            = GameObject.FindGameObjectWithTag("ExecuteTimeline").GetComponent <PlayableDirector>();
            SP            = GetComponent <SteeringParams>();
            KinematicBody = GetComponent <Kinematic>();
            SteerList     = new List <List <SteeringPlayable> >();
            //SteerList.Add(new List<SteeringPlayable>());
            LockedList          = new List <bool>();
            initiatedExternally = true;
        }
Example #6
0
        public void Align()
        {
            var targetOrientation = KinematicBody.getNewOrientation(currentGoal - transform.position);
            //rotation = goal.eulerAngles;
            var rotation = targetOrientation - KinematicBody.getOrientation();

            rotation = Kinematic.mapToRange(rotation);
            var rotationSize = Mathf.Abs(rotation);

            if (rotationSize < angularGoalRadius)
            {
                torque             = 0f;
                tiltAmountSideways = 0f;
                return;
            }

            float targetRotation;

            // if we're outside the slow Radius
            if (rotationSize > angularSlowRadius)
            {
                targetRotation = SP.MAXROTATION;
            }
            else
            {
                targetRotation = SP.MAXROTATION * rotationSize / slowRadius;
            }

            tiltAmountSideways = targetRotation;

            // Final target rotation combines speed (already in variable) with rotation direction
            targetRotation = targetRotation * rotation / rotationSize;

            torque = targetRotation - KinematicBody.getRotation();
            torque = torque / alignTime;

            var angularAcceleration = Mathf.Abs(torque);

            if (angularAcceleration > SP.MAXANGULAR)
            {
                torque = torque / angularAcceleration;
                torque = torque * SP.MAXANGULAR;
            }
        }
Example #7
0
        //public virtual DynoSteering getSteering();

        // Update is called once per frame
        public DynoSteering getSteering(Vector3 goal)
        {
            //goal = goalObject.getGoal();

            ds = new DynoSteering();

            //goal.position - transform.position;
            targetOrientation = charRigidBody.getNewOrientation(goal - transform.position);
            //rotation = goal.eulerAngles;
            rotation     = targetOrientation - charRigidBody.getOrientation();
            rotation     = Kinematic.mapToRange(rotation);
            rotationSize = Mathf.Abs(rotation);

            if (rotationSize < goalRadius)
            {
                return(ds);
            }

            // if we're outside the slow Radius
            if (rotationSize > slowRadius)
            {
                targetRotation = sp.MAXROTATION;
            }
            else
            {
                targetRotation = sp.MAXROTATION * rotationSize / slowRadius;
            }

            // Final target rotation combines speed (already in variable) with rotation direction
            targetRotation = targetRotation * rotation / rotationSize;

            ds.torque = targetRotation - charRigidBody.getRotation();
            ds.torque = ds.torque / time_to_target;

            angularAcceleration = Mathf.Abs(ds.torque);

            if (angularAcceleration > sp.MAXANGULAR)
            {
                ds.torque = ds.torque / angularAcceleration;
                ds.torque = ds.torque * sp.MAXANGULAR;
            }

            return(ds);
        }
 // Use this for initialization
 void Start()
 {
     goalObject    = GetComponent <Goal>();
     sp            = GetComponent <SteeringParams>();
     charRigidBody = GetComponent <Kinematic>();
 }
 // Use this for initialization
 void Start()
 {
     char_kinematic = GetComponent <Kinematic>();
     seek           = GetComponent <KinematicSeek>();
     arrive         = GetComponent <KinematicArrive>();
 }