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.