// Update is called once per frame void Update() { rb.velocity = new Vector2(0, -myPlayerControll.speedObjects); if (rb.transform.position.y < -15) { myPlayerControll.randomPlaceObj(coll2D, 60); } }
IEnumerator Shoot() { RaycastHit2D hitInfo = Physics2D.Raycast(firePoint.position, firePoint.up, 15); SoundMangerScript.Playsound("laserSound"); if (hitInfo) { if (hitInfo.transform.name.Contains("Coin")) { lineRenderer.SetPosition(0, firePoint.position); lineRenderer.SetPosition(1, hitInfo.point); myPlayerControll.randomPlaceObj(hitInfo.collider, 50); } if (hitInfo.transform.name.Contains("Asteroid")) { lineRenderer.SetPosition(0, firePoint.position); lineRenderer.SetPosition(1, hitInfo.point); myPlayerControll.randomPlaceObj(hitInfo.collider, 50); } if (hitInfo.transform.name.Contains("herz")) { lineRenderer.SetPosition(0, firePoint.position); lineRenderer.SetPosition(1, hitInfo.point); myPlayerControll.randomPlaceObj(hitInfo.collider, 200); } } else { // draw line lineRenderer.SetPosition(0, firePoint.position); lineRenderer.SetPosition(1, firePoint.position + new Vector3(0, 15, 0)); } lineRenderer.enabled = true; yield return(new WaitForSeconds(0.1f)); lineRenderer.enabled = false; }