- Home /
how do i enable collider on particale system from when its diabled
hi there i have a fireball particle effect that has a sphere collider on it and i was wondering if someone could point out what i am doing incorrectly as i have been staring at this for a day now and i cant under stand why i'm struggling with it i have looked online but i can't see much to do with particle system here's my code bellow hopefully someone can point out what i can not see. it has the collider not enabled when instantiated but when it instantiates after a second it enables the collider but it seems to ether always be enabled or always off
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Attack1 : MonoBehaviour
{
public GameObject ps;
private void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
FireBall();
}
}
public void FireBall()
{
GameObject go = Instantiate(ps, GameObject.Find("fireballbox").transform.position, Quaternion.identity);
go.transform.SetParent(GameObject.Find("fireballbox").transform);
StartCoroutine(Test());
}
private IEnumerator Test()
{
yield return new WaitForSeconds(1f);
if (GameObject.Find("FireballCollider").activeInHierarchy)
{
ps.GetComponentInChildren<SphereCollider>().enabled = true;
}
StopCoroutine(Test());
}
}
Your answer
Follow this Question
Related Questions
How to keep the orientation of an object unchanged when applying forces on its sphere collider? 1 Answer
How can I disable this collider, when two are present on the gameobject 1 Answer
Invert sphere collider 4 Answers
Set a variable to a collider type. 1 Answer
How to change startSpeed variable in particle system ?:( unity 5 2017.1 0 Answers