Example #1
0
 void avoid()
 {
     // inverts velocity
     Displacement    = (gameObject.transform.position - Target.transform.position);                                                  //sets the Displacement from the Target's position to the Sphere's Position
     Steering        = SteeringMag * Vector3.ClampMagnitude(Displacement - Utilities.AVec3toUVec3(agent.Velocity), 1.0f).normalized; //Uses the Displacement and the current velocity to create a steering vector
     agent.Velocity += Utilities.UVec3toAVec3(Steering / agent.Mass);                                                                // adds the steerign vector to the currentVelocity
 }
Example #2
0
    void OnTriggerEnter(Collider enemy)      //A function that is called when the enters a rigidbody.
    {
        if (enemy.gameObject.name == "Wall") //Checks to see if the Owner's barrel is a chainsaw.
        {
            if (Target.name == "Player" && PreviousTarget.name == "Boss(Clone)")
            {
                reset();
            }

            hitSource.Play();
            float mag = Utilities.AVec3toUVec3(agent.Velocity).magnitude;
            float dot = Vector3.Dot(Utilities.AVec3toUVec3(agent.Velocity).normalized, Target.transform.forward);
            agent.Velocity = Utilities.UVec3toAVec3((transform.forward) - (2 * dot) * Target.transform.forward);
        }
        if (enemy.gameObject.GetComponent <PlayerInputManager>() != null)  //Checks to see if the Owner's barrel is a chainsaw.
        {
            reset();
        }
    }
Example #3
0
 // Update is called once per frame
 void LateUpdate()
 {
     agent.UpdateVelocity();
     transform.forward  = Utilities.AVec3toUVec3(agent.Velocity);
     transform.position = new Vector3(agent.Position.x, transform.position.y, agent.Position.z);
 }