void Shooting() { GameObject projectileInst = (GameObject)Instantiate(projectiilePrefab, shootingPoint.position, shootingPoint.rotation); // Instantiate a projectile based on prefab PlasmaProjectile projectile = projectileInst.GetComponent <PlasmaProjectile>(); // Give the projectile plasma attributes if (projectile != null) { projectile.findTarget(target); // If the projectile is instantiated it needs to search for the target immediately } }
private void HandleShooting() { shootTimer -= Time.deltaTime; if (shootTimer <= 0) { PlasmaProjectile.Create(transform.position, player.transform.position); shootTimer = shootTimerMax; } }
public static PlasmaProjectile Create(Vector2 spawnPosition, Vector2 targetPosition) { Transform pfProjectile = Resources.Load <Transform>("pfPlasmaProjectile"); Transform projectileTransform = Instantiate(pfProjectile, spawnPosition, Quaternion.identity); PlasmaProjectile projectile = projectileTransform.GetComponent <PlasmaProjectile>(); projectile.SetTargetPosition(targetPosition); SoundManager.Instance.PlaySound(SoundManager.Sounds.PlasmaShot); return(projectile); }