Ejemplo n.º 1
0
 // Update is called once per frame
 void FixedUpdate()
 {
     z = -ro.GetVelMagnitude() * z_multiplier - min_z;
     if (ro.GetRotate())
     {
         cam.transform.position = Vector3.MoveTowards(cam.transform.position, new Vector3(ro.GetRot().transform.position.x, ro.GetRot().transform.position.y, z), Time.deltaTime * moveToNewRotSpeed);
     }
     else
     {
         if (Vector3.Distance(new Vector3(cam.transform.position.x, cam.transform.position.y, 0), new Vector3(transform.position.x, transform.position.y, 0)) < 0.1)
         {
             cam.transform.position = new Vector3(transform.position.x, transform.position.y, z);
         }
         else
         {
             cam.transform.position = Vector3.MoveTowards(cam.transform.position, new Vector3(transform.position.x, transform.position.y, z), (Vector3.Magnitude(gameObject.GetComponent <Rigidbody>().velocity) + 10) * Time.deltaTime * moveToBallSpeed);
         }
     }
 }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (already_moving)
     {
         if (from_player_velocity)
         {
             for (int i = 0; i < objects_size; i++)
             {
                 moving_objects[i].GetComponent <move_obstacle>().speed = objects_speed[i] * (player.GetVelMagnitude() / max_vel());
             }
         }
     }
     if (already_moving)
     {
         if (!gameObject.GetComponent <orbit>().GetOrbited())
         {
             already_moving = false;
             foreach (GameObject obj in moving_objects)
             {
                 obj.GetComponent <move_obstacle>().moves = false;
             }
         }
     }
     else
     {
         if (gameObject.GetComponent <orbit>().GetOrbited())
         {
             already_moving = true;
             foreach (GameObject obj in moving_objects)
             {
                 obj.GetComponent <move_obstacle>().moves = true;
             }
         }
     }
 }