示例#1
0
    // Update is called once per frame
    public DynoSteering getSteering()
    {
        ds   = new DynoSteering();
        goal = goalObject.getGoal();

        direction = goal.position - transform.position;
        distance  = direction.magnitude;

        if (distance > slowRadius)
        {
            targetSpeed = sp.MAXSPEED;
        }
        else
        {
            targetSpeed = sp.MAXSPEED * distance / slowRadius;
        }

        targetVelocity = direction;
        targetVelocity.Normalize();
        targetVelocity = targetVelocity * targetSpeed;
        ds.force       = targetVelocity - charRigidBody.velocity;
        ds.force       = ds.force / time_to_target;

        if (ds.force.magnitude > sp.MAXACCEL)
        {
            ds.force.Normalize();
            ds.force = ds.force * sp.MAXACCEL;
        }
        ds.torque = 0f;

        return(ds);
    }
示例#2
0
    // Update is called once per frame
    public KinematicSteering getSteering()
    {
        ks   = new KinematicSteering();
        goal = goalObject.getGoal();
        //steering = new Steering();
        Vector3 new_velc = goal.position - transform.position;

        if (new_velc.magnitude < radius_of_satisfaction)
        {
            //goalSwitcher.SwitchGoal();
            new_velc = new Vector3(0f, 0f, 0f);
            ks.velc  = new_velc;
            return(ks);
        }

        new_velc = new_velc / time_to_target;

        // clip speed
        if (new_velc.magnitude > sp.MAXSPEED)
        {
            new_velc.Normalize();
            new_velc = new_velc * sp.MAXSPEED;
        }

        ks.velc = new_velc;

        return(ks);
    }
示例#3
0
 // Update is called once per frame
 public KinematicSteering getSteering()
 {
     goal          = goalObject.getGoal();
     steering      = new KinematicSteering();
     steering.velc = goal.position - this.transform.position;
     steering.velc.Normalize();
     steering.velc = steering.velc * sp.MAXSPEED;
     return(steering);
 }
示例#4
0
    // Update is called once per frame
    public DynoSteering getSteering()
    {
        steering = new DynoSteering();

        goal           = goalObject.getGoal();
        steering.force = goal.position - transform.position;
        steering.force.Normalize();
        steering.force  = steering.force * sp.MAXACCEL;
        steering.torque = 0f;

        return(steering);
    }
示例#5
0
    //public virtual DynoSteering getSteering();

    // Update is called once per frame
    public DynoSteering getSteering()
    {
        goal = goalObject.getGoal();
        ds   = new DynoSteering();
        //goal.position - transform.position;
        targetOrientation = charRigidBody.getNewOrientation(goal.position - 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;
        }


        Logger.instance.WriteToFileDynamic("angular acceleration: " + angularAcceleration + " time: " + Time.time);

        return(ds);
    }
示例#6
0
    // Update is called once per frame
    public DynoSteering getSteering()
    {
        ds   = new DynoSteering();
        goal = goalObject.getGoal();

        direction = goal.position - transform.position;
        distance  = direction.magnitude;

        if (distance < goalRadius)
        {
            //goalSwitcher.SwitchGoal();

            //Reactivate wander
            GetComponent <DynoWander>().setWanderState(true);

            goalSwitcher.SetGoal(GetComponent <DynoWander>().goal.gameObject);
        }


        if (distance > slowRadius)
        {
            targetSpeed = sp.MAXSPEED;
        }
        else
        {
            targetSpeed = sp.MAXSPEED * distance / slowRadius;
        }

        targetVelocity = direction;
        targetVelocity.Normalize();
        targetVelocity = targetVelocity * targetSpeed;

        ds.force = targetVelocity - charRigidBody.getVelocity();
        ds.force = ds.force / time_to_target;

        if (ds.force.magnitude > sp.MAXACCEL)
        {
            ds.force.Normalize();
            ds.force = ds.force * sp.MAXACCEL;
        }
        ds.torque = 0f;

        return(ds);
    }