Hi all,
I’ve struck a bit of a seemingly random issue.
I have some code that will reduce the pitch of an AudioSource as a GameObject moves from the top to the bottom of the screen and back up again (pitch down, pitch up etc).
There is also an Animator and Animation Clip in use. The clip just cycles the colour of the sprite to give the impression of it flashing. The animator is in a state of “abducting” when this happens.
All works well and as expected.
Today I decided to change a separate Animation Clip which is used for a separate state in the same Animator. I added a reference to the AudioSource and again made a couple of tweaks to the pitch. This was so that it would be changed as certain points during the animation. This is a separate state and separate clip to the one described above which cycles the colour - my point here being that they are utterly separate, do not execute at the same time, the only thing they have in common is the Animator.
When I ran the game, the code which made the pitch changes (pitch down/pitch up) seemed to no longer work. Having investigated, it was working, but it would seem that the values were getting overridden.
The moment I removed the changes to the other Animation Clip, which had the references to the AudioSource the code behaved as it should again.
I’m a little bit confused by this, as the Animator doesn’t go into the state where the clip references to the AudioSource under this condition, yet the references to the AudioSource seem to cause problems.
I was reluctantly adding these pitch changes to the Animation Clip in the first place, but it seemed like a quicker way to achieve the end result I was after. This feels like a bug, but perhaps I’m missing something.
In the second Animation Clip I refer to here, the pitch is set at 1 and increased just before the end of the sprite changes. It’s by belief that this is overriding the changes I’m trying to make in code - yet these two events should not be executing at the same time anyway, and certainly are no when you watch the Animator.
Has anyone had any similar issues? I’m currently running 2018.3.7
Just ran another quick test before posting this, I added the AudioSource property back to the Animation Clip, associated with the state that isn’t executed and again, it seemingly prevents the code from running, e.g. I don’t here the pitch changes being executed via the code, thus, reproducible.