- Home /
particle system isn't visually there
i'm creating a simple game with a player and an enemy. but whenever it hit the enemy, i want there to be a particle system. when i'm playing the game, it says in the hierarchy that the particle system has played, but it didn't visually. does anyone know how to fix this?
here is my script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class cube : MonoBehaviour {
public Gamemanager manager;
public float moveSpeed;
public Vector3 respawnPoint;
public GameObject deathParticles;
private Vector3 input;
// Use this for initialization
void Start () {
moveSpeed = 7f;
manager = manager.GetComponent<Gamemanager>();
respawnPoint = transform.position;
}
// Update is called once per frame
void FixedUpdate () {
transform.Translate (moveSpeed * Input.GetAxis ("Horizontal") * Time.deltaTime, 0f, moveSpeed * Input.GetAxis ("Vertical") * Time.deltaTime);
if (transform.position.y < -3) {
die ();
}
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Enemy") {
die ();
}
if (other.transform.tag == "goal")
{
manager.CompleteLevel ();
}
}
void die ()
{
Instantiate (deathParticles, transform.position, Quaternion.identity);
transform.position = respawnPoint;
}
}
Probably the scale of your deathParticles is too small, try increase the transform.scale of the prefab in project folder. If your particle prefab has child particle system objects, make sure they use "hierarchy" scaling mode.
Answer by Litleck · Sep 23, 2017 at 01:05 PM
If you have your particle system disabled before instantiating it wont work, you'll need to either enable the copy of it or use a different way called emit. You specify a number of particles and it will create that many. I've included documentation on this.
https://docs.unity3d.com/ScriptReference/ParticleSystem.Emit.html
Your answer
Follow this Question
Related Questions
Particle system increases/decreases in size depending on camera proximity 2 Answers
Particle System UI in Pro vs Free 0 Answers
Particle System(Shuriken) optimization problem 1 Answer
(legacy) Changing color only of new particles 1 Answer
How to make a particle system emit more than 1 particle at once. 1 Answer