- Home /
Animation won't play when changing position
I am using the Shockwave animation found in the Simple Particle Pack - https://www.assetstore.unity3d.com/#/content/3045
I have dragged the animation onto my hierarchy view and positioned it in the middle of my GUI. What happens is the animation will play on awake as that is set to true, however when I try and move the prefab to a particular location in the code and then call Play(), nothing happens.
Here is the setup of the positions and the particle system:
public ParticleSystem cardTakenAnimation;
void setBoardPositionsForAnimation()
{
//1-1, 1-2 etc...
boardPositions[0] = new Vector3(-235.5366f, 160.0073f, -220.0208f);
boardPositions[1] = new Vector3(-32.19697f, 160.0073f, -220.0208f);
boardPositions[2] = new Vector3(190.058f, 160.0073f, -220.0208f);
boardPositions[3] = new Vector3(-235.5366f, -133.1802f, -220.0208f);
boardPositions[4] = new Vector3(32.19697f, -133.1802f, -220.0208f);
boardPositions[5] = new Vector3(190.058f, -133.1802f, -220.0208f);
boardPositions[6] = new Vector3(235.5366f, -407.4523f, -220.0208f);
boardPositions[7] = new Vector3(32.19697f, -407.4523f, -220.0208f);
boardPositions[8] = new Vector3(190.058f, -407.4523f, -220.0208f);
}
Here is what I am doing when a certain event happens in order to move the particle system and play the animation.
cardTakenAnimation.transform.position = boardPositions[0];
Debug.Log("Position: "+animationObject.transform.position);
cardTakenAnimation.startColor = Color.red;
cardTakenAnimation.Play();
I'm finding that the Debug.Log is printing the correct position, but no animation is playing which I find odd. Does anyone have a clue as to what I'm doing wrong?
Comment