I’m creating a boss that needs to instantiate a bunch of ‘particles’ which launch left and right. The particles are instantiated from an animation with event triggers (The code below is the entire code, in-case the problem may be in the code itself);
public class CandyBoss : MonoBehaviour
{
public GameObject CandyCone, CandyConeColliders, CandyConeColliders2, ParticleRT, ParticleRB, ParticleM, ParticleLT, ParticleLB;
public Transform CandyConeTransform, ParticleInstantiater;
public Shaker ShakerScript;
public GameObject[] Platforms;
private Animator Anim;
void Awake()
{
Anim = gameObject.GetComponent<Animator>();
}
public void Turn()
{
if(transform.localScale == new Vector3(1,1,1))
{
transform.localScale = new Vector3(-1,1,1);
}
else if(transform.localScale == new Vector3(-1,1,1))
{
transform.localScale = new Vector3(1,1,1);
}
}
public void Bumped()
{
for(int i = 0; i < Platforms.Length; i++)
{
Platforms*.SetActive(true);*
-
}*
-
ShakerScript.Anim.SetBool ("Shaking", true);*
-
Instantiate (CandyCone, CandyConeTransform.position, gameObject.transform.rotation);*
-
Destroy(CandyConeColliders);*
-
}*
-
public void StartThrowing()*
-
{*
-
Anim.SetBool("Throwing", true);*
-
}*
-
public void ThrowRightTop()*
-
{*
-
Instantiate(ParticleRT, ParticleInstantiater.position, gameObject.transform.rotation);*
-
}*
-
public void ThrowRightBottom()*
-
{*
-
Instantiate(ParticleRB, ParticleInstantiater.position, gameObject.transform.rotation);*
-
}*
-
public void ThrowMiddle()*
-
{*
-
Instantiate(ParticleM, ParticleInstantiater.position, gameObject.transform.rotation);*
-
}*
-
public void ThrowLeftTop()*
-
{*
-
Instantiate(ParticleLT, ParticleInstantiater.position, gameObject.transform.rotation);*
-
}*
-
public void ThrowLeftBottom()*
-
{*
-
Instantiate(ParticleLB, ParticleInstantiater.position, gameObject.transform.rotation);*
-
}*
}
I have no idea what I’ve done wrong, but the particles are not always instantiated at the ‘ParticleInstantiater’ position (The instantiater is immobile ). Instead, they have some sort of 50% chance to be instantiate BELOW the transform (and how low it is is also random). If I lower the game’s speed (Time.timeScale = 0.2f), then the chance to instantiate below the transform is lowered. I have tried using an array to instantiate the particles, but the result is the same. The build version doesn’t change this either.