示例#1
0
 // Update is called once per frame
 void Update()
 {
     transform.position = VecLib.VectorAdd(transform.position, VecLib.ScalarMult(Velocity, Time.deltaTime));                                              // Adds velocity vector to the position vector of the ball
     Collision          = VecLib.RadiusCheck(transform.position, ball2.transform.position, transform.localScale.x / 2, ball2.transform.localScale.x / 2); // collision check
     if (Collision == true)
     {
         Collisionball();
     }
 }
示例#2
0
 // Update is called once per frame
 void Update()
 {
     transform.position = Veclib.VectorAdd(transform.position, Veclib.ScalarMult(Velocity, Time.deltaTime)); // adding the velocity to the position of the ball
     Velocity           = Veclib.VectorAdd(Velocity, Veclib.ScalarMult(Acceleration, Time.deltaTime));       // changing the velocity
     if (transform.position.y < groundHeight)
     {
         Velocity.y = Mathf.Abs(Velocity.y) * Coefficient; //velocity after collision (coefficient of restitution)
         if (Velocity.y < Tolerence)
         {
             Velocity.y = 0; // makes it stop bouncing
         }
     }
 }
示例#3
0
 // Update is called once per frame
 void Update()
 {
     distance = VecLib.VecMag(VecLib.VectorSub(transform.position, paths[target].transform.position)); // finds the distance between the square and the waypoint.
     if (distance < Tolerence)                                                                         // if the distance is less that the tolerance then the target changes
     {
         target++;
         if (target >= paths.Length) // if there is no other targets the cube goes back to the first target.
         {
             target = 0;
         }
     }
     VecTemp            = VecLib.UnitDirVec(paths[target].transform.position, transform.position); // holds the unit vector between the waypoint and the square
     Vel                = VecLib.ScalarMult(VecTemp, speed * Time.deltaTime);                      // makes the velocity the unit vector * speed
     transform.position = VecLib.VectorAdd(transform.position, Vel);                               // adds velocity to the position of the cube (allows to move).
 }
 // Update is called once per frame
 void Update()
 {
     transform.position = VecLib.VectorAdd(transform.position, VecLib.ScalarMult(Velocity, Time.deltaTime)); // Adds velocity vector to the position vector of the ball
 }