Hey, been a while since I’ve sought out any type of advice or assistance. I discovered today something peculiar regarding having my enemy’s sprite renderer material switch temporarily into a ‘hurt’ material before switching back to the original material it uses at the end of an animation.
Regarding Material For Hurt Effect:
Some of my enemy sprites didn’t come with a ‘hurt’ animation, so I simply created one. In order to reflect a distinct look of the enemy being ‘hit’ I recorded and switch out its sprite renderer material for another material that just displays the sprite completely white with its own outline still visible. Before the animation ends, I simply make the original material in use again. Very basic stuff.
Anyways, that works fine.
However, on a script each enemy and player has access to is a OnMouseOver method that also temporarily switches out that sprite’s material for an outline material I made customly to highlight that sprite. That script in a start function captures and saves the sprite’s material they enter with, so it’s pretty basic and simple and works.
Thus, you’d cursor over the box collision and then the script switchs that original material with a outline material, then once on OnMouseExit is called it simply puts back the captured material.
Except now that I’ve made my custom animation ‘hurt’ which is also using sprite renderer’s material, it seems to just completely override my script from ever allowing that material to be changed even though that animation isn’t even playing currently.
Why is the animation negating and not allowing my script to change anything regarding it’s material now that I had recorded a material swap for a hurt effect anim?