Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        transform.Translate (0, 0, currentSpeed * Time.deltaTime);

        Ray ray = new Ray (transform.position, transform.forward);
        RaycastHit hit;
        // Check for collisions
        if (Physics.SphereCast (ray, 0.75f, out hit)) {
            if (hit.distance < obstacleRange) {
                float angle = Random.Range (-110, 110);
                transform.Rotate(0, angle, 0);
            }
        }

        rT = GetComponent<reactiveTarget> ();
        if (rT.currentHp < 100) {
            currentSpeed = runSpeed;
            Debug.Log(currentSpeed + " Speed der ");
        }
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0) &&
         !EventSystem.current.IsPointerOverGameObject())
     {
         Vector3 point = new Vector3(
             _camera.pixelWidth / 2, _camera.pixelHeight / 2, 0);
         Ray        ray = _camera.ScreenPointToRay(point);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit))
         {
             GameObject     hitObject = hit.transform.gameObject;
             reactiveTarget target    = hitObject.GetComponent <reactiveTarget>();
             if (target != null)
             {
                 target.ReactToHit();
             }
             else
             {
                 StartCoroutine(SphereIndicator(hit.point));
             }
         }
     }
 }