Hello there. This is a continuation of an older thread. (https://adventurecreator.org/forum/discussion/13151/link-variable-to-animator-sanity-hp-mechanic#latest) <- I've added link for context.
I was able to set up the Sanity/HP just fine (with help from this forum). My question is in regards to "Link Variable to Animator" in relation to Canvas. Can I set this up in any way so that it acts like UI, or do I need to work around it and attach the object (animated portrait) to the player, or make the mechanic static/cinematic?
The current logic is as follows: Whenever the character gets a -1 or +1 point on the linked variable, the Animated Portrait appears, plays an animation, and fades out. I'd like it to act like UI, but it appears that animations don't play via "Link variable to Animator" in Canvas.
Is there any other workaround, or should I just attach it to the character and have it mimic Canvas UI that way?
As always, thank you in advance, and have a wonderful day ahead!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
There's no restriction preventing the component's presence on a Canvas - is this as part of an AC Menu, or is the Canvas not linked to AC?
If you're having trouble using it, share screenshots of all concerned - the Variable, the Canvas Inspector, and the Animator.
One thing to note is that - if you only need the Variable to affect the Animator, and not the other way around - set the Variable's "Link to" field to "None". That'll cause a one-way update and the Animator should be updated each frame.
I'm getting the following error "Animator is not playing an AnimatorController" whenever I try set-up the UI with Canvas. I've attached my set-up for Canvas and also a video showing the error, and the old version that is working of the UI.
https://drive.google.com/file/d/1lu5-Wbpkjm0SKQDSTqVwkw8GIs6q1JDV/view?usp=sharing < - the set up
https://drive.google.com/file/d/1D-Fo-N1mGWCd7tVW2mf8o4SFscCExHhT/view?usp=sharing <- the video
as always, thank you
The warning message you're getting is coming from Unity, and will display if the Animator it's trying to control is not enabled and in the scene.
Your screenshot suggests that the Animator assigned in the Link Variable To Animator component (UI Test) is not the same as the one attached to the same GameObject (Image). You should typically have these two components be attached on the same object, and the object will need to be active in ths scene.
My appologies for that, I didn't notice that mistake. I changed it, but the animations still don't play. And there's no more error this time. Here's the new set-up.
https://drive.google.com/file/d/1zlGWxQ0fMV-nAHA2eGZhkFufN1fez_4t/view?usp=drive_link
and here's a video
https://drive.google.com/file/d/1zAC4NN2XC8FFm67YRSfQPJnTrUVrS7b0/view?usp=drive_link
I'm afraid the video link is restricted.
https://drive.google.com/file/d/1zAC4NN2XC8FFm67YRSfQPJnTrUVrS7b0/view?usp=sharing <- here it is again. sorry about that
What of the Animator window during this time? Does it similarly have an Integer parameter named "SanityCheck"?
Is the Image GameObject/Image component being affected by anything else, such as a MenuGraphic element?
I found the fix. I think it was a unity issue, or I don't know what. The reason why the animations weren't playing was due to the animator seeing the sprites as "missing" , even though the Animator was the same. I manually added the sprites again, and the animator and variable seem to update properly now. I apologize for wasting your time; I should have checked the animator twice.