Threw countless DAYS of trying to figure out how the hell to use Mecanim to play a simple animation file, I still have no idea how to play a simple animation on my character when my character enters a trigger. To my understanding, Mecanim does not Play single animations. It looks like I need at least an Idle animation as the starting state and then the actual animation that Idle will transition to the animation state. I tried to drag my single animation file into the animator window which left a Green bar labeled Entry with a transition to my animation file.
Supposedly this will not work as the HUNDREDS of threads and countless videos have Idle as a starting state then the animation to transition too. Am I correct in that I need a starting animation and then another to transition too? Why the hell can I not have a single animation play in mecanim? it needs all these complicated transitions from idle to the animation state I actually want to trigger when entering a trigger in gameā¦
You can easily create an animation in Unity for your idle, with no movement in it. Then, you just drag that animation in first, and then your other, action, animation into the Animator Controller. You create a parameter to handle the trigger, and then create a transition from the idle to your action. In that transition, you make it triggered by your parameter. Then, you might want to make a transition back to idle, which use can do when the animation ends, or triggered by another parameter. Itās actually pretty simple.
Seems like your having a heck of a time seeker. I can relate.
medhue gives some great advice, but in this instance I donāt think that process is needed initially.
Removing the trigger from the equation - because thatās an additional issue which doesnāt need to be compounded upon the first problem, did you ever figure out the issue of getting a single animation to play without idle?
If not check this for reference.
Setting the animation you have as the default state should play automatically as long as the character controller is set up properly.
Additionally you mentioned having problems importing animations setup as legacy and generic and the animation not playing. The rig, avatar and animation have to match in order for the animation to play properly.
If you only want one animation state as soon as the character controller is initialized the animation will play. But you want to pause this animation state until the trigger is activated. I believe setting the animator speed to 0 will pause, and setting it back to 1 will play normal playback.
The trigger can be the pause / unpause, though Iām no coder so I donāt know how efficient this is .
Additionally you could use the technique medhue suggested and set the transition to happen on trigger enter.
If youāve already solved the single animation issue - here are a couple recent trigger related posts which may be helpful.
Iām not a coder so I canāt accurately decipher the code you posted in the other thread, but these may help.
If you continue to struggle with code you may want to consider Playmaker from the asset store.
Itās been a godsend for me personally.
I would draw your attention to what a dev said: [quote]
as soon as you have one clip animating a property the animator take control of this property and start to write value. The only way to override this value is to write this value after the animation step in a LateUpdate callback.
[/quote]
In my case (i was wanting to only play ONE animation at the right time) I have ended up just disabling the mecanim component completely to stop it screwing with my stuff when its animation is not required
Mecanim describes non character animation as āgenericā, well youāre generic mecanim, youāre genericly bad at the basics that the legacy system got right.
I think it really depends on how you like coding these things, or if you are a coder vs an animator. Me, I love mecanim, whether for characters or not. Iām not saying it could not be improved, but it does make things easy. Iāve actually had to force coders to use it too, on a number of jobs. Once they dig deeper into mecanim they understand why it is good to use. Now, when I do make animated non character items for games, I include the animator controller, just so the coder can see how Iām using it.
concur medhue. Personally I hate even having to attach a copy/paste script to things because I feel like Iām loosing control of whatever it is. I bet a lot of coders feel the same way when they have to use something visual like mecanim instead of keeping total control of everything via code.
I havenāt used mecanim beyond character setup yet, but I will be soon. Sorry for changing subjects.
Wonder which workable solution OP @sunseeker1988 used.
@medhue : I think I came off a bit too snarky, but iām not coming from a coding angle here, iām absolutely on the art side of things
I would point out that from an animation point of view the workflow of animating positions, rotations, colors & properties etc is identical to the legacy system - & i do like it - unity is excellent on the editor preview performance side of things.
Its just the behaviour of the animator when you set a keyframe that seems confused to me. It should only ātake control of this property and start to write valueā when its on a state with that animation.
Its behaving a more like a fixed global timeline that a state machine & should treat states with animations attached as individual timelines - thats what they are after all.
I think its not doing what I want because I have the parameters, conditions and my code not working together as it should. I want my main character ātronā the paddle to animate once when it comes into contact with the white box. Im not sure I have my scripting, parameters and conditions set up correctly to achieve this. I made a video to show you guys what Iām working with. Iām very new to all of this so from the bits and pieces ive tried to gather from various videos and websites I think I still do not have it set up properly.
I do want to let you all know the animation āIdleā dose not animate. I only created an idle animation because all of the videos I watched had Idle as the starting animation and THEN transitioned to the animation they wanted animated. I do not have to use Idle animation if thats an option for animating from entry to Bumpā¦Iām just lost here
After watching the video, you do have a problem with your parameters, and this could be causing all your issues. So, you have the default idle, and that transitions into the bump animation and then back to idle. The transition in, should probably be a boolean, set to true. The transition out of the bump animation should not use the bump parameter to go back to idle. What it should use is time. If you set no parameter, then the transition will use time as itās default.
What you have in the video, is the transition in, and transition out, using the exact same trigger, so the bump animation never actually plays. So, the system is being told by you to goto this bump animation, but then immediately back to idle. I hope everything Iām saying makes sense.
It does make sense thanks a ton. I had a trigger on my main character. I took the trigger off and left the trigger on the cube and it works. It plays the animation when my character comes into contact with the trigger on the cube, but my animation plays over and over in a loop. i just want the animation to play once.
awsome it works but when my character enters the trigger for a second time it will not play any animation again no matter how many times it moves into the trigger.