void SpawnThrustParticles() { ThrustParticle thrustParticlePrefab = _thrustParticlePrefabs[Random.Range(0, _thrustParticlePrefabs.Count)]; float randomX = Random.Range(-_distanceBetweenParticles, _distanceBetweenParticles); float randomY = Random.Range(-_distanceBetweenParticles, _distanceBetweenParticles); Vector3 spawnPosition = new Vector3(_particleSpawnPoint.position.x + randomX, _particleSpawnPoint.position.y + randomY); Instantiate(thrustParticlePrefab, spawnPosition, transform.rotation); }
void SpawnParticle() { if (canSpawnParticle) { float randX = Random.Range(-3, 3); float randY = Random.Range(-3, 3); ThrustParticle thrustParticle = Instantiate(_thrustParticlePrefab, new Vector3(transform.position.x + randX / 10, transform.position.y + randY / 10, transform.position.z), transform.rotation); Vector3 forceToApply = new Vector3(randX, randY, -_backwardForce); thrustParticle.rigidbody.AddRelativeForce(forceToApply * 2); thrustParticle.Init(); } }
public void CreateThrustParticles() { float offsetX = Random.Range(-.2f, .2f); float offsetY = Random.Range(-.2f, .2f); Vector3 currentPos = this.transform.position; Vector3 spawnPos = new Vector3(currentPos.x + offsetX - .1f, currentPos.y + offsetY, 0); if (currentArmor > 1) { ThrustParticle thrustParticle = Instantiate(_fullHealthThrustParticlePrefab, spawnPos, this.transform.rotation, this.transform); } else { ThrustParticle thrustParticle = Instantiate(_noHealthThrustParticlePrefab, spawnPos, this.transform.rotation, this.transform); rigidBody2D.rotation += -0.2f; rigidBody2D.gravityScale += 0.006f; } }