private void FireProjectile() { cursorInWorldPos = cam.ScreenToWorldPoint((Vector2)Input.mousePosition); direction = cursorInWorldPos - (Vector2)transform.position; direction.Normalize(); newProjectile = poolingManager.SpawnFromPool(projectilesPoolTag, transform.position, Quaternion.Euler(0, 0, Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg)); newProjectile.GetComponent <Rigidbody2D>().velocity = direction * CONST_VALUES.PROJECTILE_SPEED; shootingSound.Play(src); }
private void ShootAtTarget() { shootingSound.Play(src); bulletDirection = target.position - transform.position; bulletDirection.Normalize(); newProjectile = poolingManager.SpawnFromPool(projectilesPoolTag, transform.position, Quaternion.Euler(0, 0, Mathf.Atan2(bulletDirection.y, bulletDirection.x) * Mathf.Rad2Deg)); newProjectile.GetComponent <Rigidbody2D>().velocity = bulletDirection * CONST_VALUES.PROJECTILE_SPEED; shootingSound.Play(src); }
private IEnumerator SpawnInterval() { yield return(waitForIntervalDuration); for (int i = 0; i < enemiesPerSpawn; i++) { newEnemy = poolingManager.SpawnFromPool(desiredEnemy.enemyTag, GetRandomPositionOnCircle() * RADIUS, Quaternion.identity); newEnemy.GetComponent <EnemyController>().desiredEnemy = desiredEnemy; onEnemySpawned.RaiseEvent(); } yield return(SpawnInterval()); }
private void FireProjectile() { newProjectile = poolingManager.SpawnFromPool(projectilesPoolTag, transform.position, transform.rotation); newProjectile.GetComponent <Rigidbody>().velocity = transform.forward * PROJECTILE_SPEED; }