Hello there, been a while! In my PNC adventure game, I have an NPC who is sweeping the floor with a broom (it's an idle animation). If the player talks to this character, I'd like for the character to stop the sweeping and then turn towards the player character. However, the exact moment when a player chooses to talk to this NPC can be at any time during the sweeping cycle, so obviously most of the time the change from the idle to the turning animation looks abrupt. I'd like for it to be smooth.
The end of the sweeping animation cycle is where the broom is at a position that would play well together with the beginning of the turning animation. So my question is: as the TALK TO command is given by the player, is there an ActionList command I haven't yet realized that would let the idle animation loop run to the end of the current cycle and ONLY THEN play the following animation? Or how else could this be achieved? Many thanks beforehand!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Welcome back, @luuk!
Is this for a 2D or a 3D game, and does the charater have a dedicated "turning" animation? One thing you could try is the "Has Exit Time" property of your Idle -> Turning transition, to ensure it only transitions at the end of the Idle loop.
You could then feasibly have a simple script that ties the NPC's "Turn speed" value to the playback of the turning animation itself, so that they don't rotate until Idle has finished playing.
2D, always 2D.
And Sprites Unity. It's a Monkey Island style retro pixelart game with no head/body turning towards objects/characters or dedicated turning animations, so this one is really a special occasion where the sweeping NPC has her back towards the player until she's talked to. So actually what I mean is just a broader case of wanting to "play this character animation now, but only after the current idle animation loop cycle has finished, because that way the switch between the animations looks smooth".
I'd have other uses for the same idea, too, that aren't about turning, so a solution which wouldn't rely on the character turning features would likely be better (unless this happens to solve all such cases – I have to admit I hadn't looked into the specifics of what the turning features of AC offer yet, because I was thinking about the other uses, too – but for what I'm going for, from what I now glanced at, the manual doesn't seem to cover it that much).
Thanks for the details.
It's a bit tricky, but you should be able to do this by introducing a "Wait" bool variable that is set to True while the sweeping animation is playing, and have your ActionList wait until this is set to False.
Essentially:
SetWaitBool.cs:
Thanks a lot for this Chris, it should prove very useful in the future. However, the thing is, for this NPC, I have over 50 animations setup already using Sprites Unity. From the looks of it, Sprites Unity Complex seems to handle animations so differently that the amount of work required to change animation engines for the character at this point seems a bit overwhelming. Therefore, I'm left to wonder if there's some way, some sneaky detour to accomplish what I'm going for while sticking to Sprites Unity, even if that's not the most smart or natural way to go about it? I'm sorry to be a pain – feel free to ignore this comment.
Maybe.
Currently, if you run a Character: Animate Action's Play Custom method, it'll restart the supplied animation even if it's currently already playing.
You can prevent this by opening up AC's AnimEngine_SpritesUnity script and pasting the following into line 285:
What this should mean is you can then begin the sequence by re-running the Idle animation using this Action, with Wait until finish? checked, so that it then continues to play the animation until it finishes it's current run of the loop.
Thanks a lot, that solution makes sense and I hope it'll work! However, I made the mistake of not reiterating that I'm still using the version of AC I started this game with back in 2020 (v1.72.4) and I'm betting that's why line 285 probably isn't the correct place for this script bit... but in the off chance it is, here are the error messages I get:
Another thing I wanted to ask is whether there's a way to donate to you? This forum and your tireless contribution to it is second to none, and I think paying for AC once years ago isn't quite enough. I'd like to show my appreciation of your amazing dedication in helping us make our dreams come true.
Yeah, this'll be a different line then. Instead, best to look for the following in the ActionCharAnimRun function and paste it underneath:
Well, let's see if we can get the above issue solved first! Happy to share details over PM, but please don't feel obliged.