- Home /
Change Idle/Walk player animation permanently on trigger colliders
Hey,
Relatively new to Unity but for the most part I am learning lots thanks to the great community here and I’m making good progress so far.
One thing I’d like to do in my game which I can’t seem to find any answers for in particular, is how would I go about scripting that when my player triggers a collider, the player's movement animations (Idle/Walk) change to new animations permanently? I don't mean that on triggering the collider I want the player to play a brief animation, what I mean is that I want the collider trigger to completely switch the animations used for my Walk/Idle permanently.
The idea is that the player collects objects and each time they do, their movement improves. Like a power up. So for example if I've collected 0 objects I would be using Idle1, Walk1. If I've collected 1 objects, it would be Idle2, Walk2. If I have 2 of the objects, I would be using Idle3 and Walk3... etc etc.
I already have a hud UI that records which quantity of objects the player has collected, and all of my trigger collider collectible objects set up and working. The walk animation plays when I press the W key to move forward, the idle animation plays at rest.
I want to do this animation change five times total. I’m not sure whether it would be best to do this inside my existing animator controller, or whether it’d be best if the script would change the player to a different animator controller, which would mean I’d need five animator controllers.
Any pointers to start building this process would be greatly appreciated!
Thanks in advance
Answer by TomArano_Dimenco · Mar 13, 2020 at 12:40 PM
dont really have any pointers but it seems like you have most of it figured out, using different animators sounds like a good idea than you do not have to write that many switch cases/if statements. It's always gonna be trail and error when making a game so just go and try.
good luck!