Exemple #1
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0) &&
            Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
        {
            if (hit.collider.CompareTag("Enemy"))
            {
                Time.timeScale = 0.5f;
                isShoot        = true;
                placeShoot     = hit.collider.gameObject;

                Vector3 shootDirection = bullet.position - hit.point;
                shootDirection.Normalize();

                enemy.EnablePhysics();
                placeShoot.GetComponent <Rigidbody>().AddForce(shootDirection * -attackForce);
            }
        }
    }