// Update is called once per frame
 void FixedUpdate()
 {
     if (ballScript.CheckForPass(transform))
     {
         float   d         = Vector3.Distance(transform.position, ball.transform.position);
         Vector3 onBarrier = ball.transform.position - (transform.up) * d;
         if (Vector3.Distance(onBarrier, transform.position) < transform.localScale.x * 1.1f)
         {
             if (Vector3.Dot(ballScript.GetDir(), -transform.forward) < 0f)
             {
                 ballScript.ReflectDir(-transform.forward);
             }
         }
     }
 }
 // Update is called once per frame
 void FixedUpdate()
 {
     if (ballScript.CheckForPass(transform))
     {
         float   d         = Vector3.Distance(transform.position, ball.transform.position);
         Vector3 onBarrier = ball.transform.position - (-transform.forward) * d;
         if (Vector3.Distance(onBarrier, transform.position) < transform.localScale.x / 1.4)
         {
             if (Vector3.Dot(ballScript.GetDir(), -transform.forward) < 0f)
             {
                 ballScript.SetVelocity(0f);
                 ballScript.SetInit();
             }
         }
     }
 }
Beispiel #3
0
 // Update is called once per frame
 void Update()
 {
     if (ballScript.CheckForPass(transform))
     {
         float   d         = Vector3.Distance(transform.position, ball.transform.position);
         Vector3 onBarrier = ball.transform.position - (-transform.forward) * d;
         if (Vector3.Distance(onBarrier, transform.position) < transform.localScale.x / 1.2)
         {
             if (Vector3.Dot(ballScript.GetDir(), -transform.forward) < 0f)
             {
                 ball.transform.position = exitPoint.position;
                 ballScript.SetDir(-exitPoint.forward);
             }
         }
     }
 }