- Home /
Is it possible to scale particle effect in Unity 5?
I saw quite a lot of similar questions but they are 3-4 years old, so is it possible to do it in Unity 5?
Here is a small part of my script:
using UnityEngine;
using System.Collections;
public class Colisions : MonoBehaviour
{
public GameObject explosion1;
private GameObject explosion;
void OnTriggerEnter(Collider other) // If object which has this script collides with any other object
{
if(gameObject.tag == "Asteroid") // I'm setting different effects for different objects here
{
explosion = explosion1;
/* I want to scale particle effect here pseudo - explosion.scale += 2 */
}
if (other.gameObject.tag == "Bolt") // If current object collides with bolt
{
gameObject.GetComponent<Soul>().damage(other.gameObject.GetComponent<Bullet>().devast, other.gameObject.GetComponent<Bullet>().type); // Each object has a 'Soul' class attached, it holds settings and health, it also has damage function which calculates damage, here I send damage and attack type from a Bolt object
if (gameObject.GetComponent<Soul>().health <= 0) // If current object has no health
{
Destroy(gameObject); // This object gets destroyed
Instantiate(explosion, transform.position, transform.rotation); // Here I add particle effect, but I want to scale it
}
Destroy(other.gameObject); // Bolt is also destroyed here
}
}
}
Have a look at lines 18-19, there I want to scale a particle system, but I'm not sure if it's possible.
Also suggestions on how to improve this script are welcome too.
Do you want to change the scale of the particles, or the scale of the emitter? For the former, change the ParticleSystem's Particle Starting Size. For the latter, scale the whole gameobject.
I want to change scale of the emitter, I want to be able to set scale of the particle effect from my script. And I can't just scale gameobject because particle effect doesn't belong to any game object, i just simply add particle effect like this:
Instantiate(explosion, transform.position, transform.rotation);
I tried many things, like explosion.LocalScale, it doesn't work.
Okay... The GameObject you instantiate for the explosion: Does this GameObject have a ParticleSystem component?
Answer by Wolf_Tech · Sep 26, 2015 at 05:50 PM
Not 100% but heres how I would do it.
GameObject particle = Instantiate(explosion, transform.position, transform.rotation) as GameObject;
particle.transform.scale = new vector3 (x,y,z);
Thats how I would expect it to work, let me know how it goes.
This would work on ordinary objects. Still I tried it but no, doesn't work. Actually it's strange if unity doesn't support this, because even old game like warcraft III has support for scaling particle effects:]
Your answer
Follow this Question
Related Questions
Random Non-uniform Particle Start Size? 1 Answer
Non-uniform scaling in Particle effects not working on Unity 2017 0 Answers
particle system scaling 1 Answer
Particle Scaling for Particle-UI-Elements 0 Answers
Make UI Particle System not scale 0 Answers