Example #1
0
 void Update()
 {
     distance = Vector3.Distance(truck.transform.position, transform.position); // check distance between the two objects
     if (distance < 10f)
     {
         Vector3 pos = this.transform.position;
         Destroy(this.gameObject); //Destroy this object the create "Explosion" in same position
         for (int i = 0; i < 300; i++)
         {
             Instantiate(cube, pos, Quaternion.Euler(Mathf.Sin(Time.time), Mathf.Sin(Time.time), Mathf.Sin(Time.time)));
         }
         GameScore.AddScore(50); // 50 pts for discovering the explosive cube
     }
 }
Example #2
0
        void Update()
        {
            distance = Vector3.Distance(obj.transform.position, truck.transform.position);

            if (distance < desired_distance)
            {
                if (obj == GameObject.FindGameObjectWithTag("dog") && !dog_found)
                {
                    GameScore.AddScore(50);
                    dog_found = true;
                }
                //If less than specified desired distance create popup
                text_mesh.enabled = true;
            }
            else
            {
                //do not create popup
                text_mesh.enabled = false;
            }
        }