Forum rules - please read before posting.

Tween based animation problem.

I have some of my dialogue UI animated via tweens. The dialogue pictures have a tween script that gets called upon start which makes them slide into place. When the menu is set to show when speaking these work perfectly. They zip in each time someone speaks without any issue. I want, however, as part of my dialogue system to sometimes have multiple portraits on screen at the same time. I used something based on the Gabriel Knight system to get this working but it requires switching the menu system to manual. This does work with one caveat, the tween animation only plays the first time that portrait is called into the conversation. The portraits switch as normal but the animation will not play. I have tried turning them on and off and hiding them but it is as though it thinks the menu is still there in the background even when it is turned off and is keeping the previous position. Is there a way around this? Would I be better doing this with an animation that could be triggered rather than a script? Hopefully someone else had this issue and knows a way around it?

Comments

  • A script can certainly be used - but depending on how it's intended to be used, it may need to be triggered manually when the Menu turns on.

    You can run a custom script function by hooking into the OnMenuTurnOn custom event and filtering out the intended menu by it's title, e.g.:

    void OnEnable () { AC.EventManager.OnMenuTurnOn += OnMenuTurnOn; }
    void OnDisable () { AC.EventManager.OnMenuTurnOn -= OnMenuTurnOn; }
    
    void OnMenuTurnOn (AC.Menu menu, bool isInstant)
    {
        if (menu.title == "Conversation")
        {
            // Run some custom code here when the Menu "Conversation" is turned on
        }
    }
    

    A tutorial on working with custom events can be found here.

  • I shall give that a go now. Thank you. It looks similar to how I got it to read if my text had stopped scrolling to make it show a next button and that worked so fingers crossed this does the trick. I'd tried something similar to this by setting a custom variable but I lost in the gobbledegook of trying to get my script to read the global variable and couldn't get it to work. Hooking into the OnMenuTurnOn seems like a much better idea. I'll let you know how I get on. Thank you again.

  • Sadly that doesn't seem to work. I set up a quick debug.log to fire when the menus are turning on and using whenspeechplays does trigger with the OnMenuTurnOn but using manual only works the first time the menu is called into the conversation. All subsequent times the menu is turned on don't seem to count. Maybe I can set something up to switch with an OnMenuTurnOff? I'll try and fiddle a little before work.

  • When is the Menu being turned off - after each line, or after the whole sequence?

  • The issue arises when I turn things off during a talk action sequence. Which I often have to do when characters change/leave or something like a conversation choice occurs.
    Before I left for work I did manage to something to sort of work when the menu was turned on and off but it was jerking my portraits around to weird and wonderful places I didn't tell them to go, which means it must be possible even if I messed it up before.
    I will have another look at it when I sit down in a few hours and see what I can do.
    I do appreciate the help though. I am still getting my head around Unity and I'm a much better Illustrator/3D artist than I am a coder.
  • You can use Debug.Log statements inside your various event hooks to print messages in the Console - this will help work out which ones are being run and when.

    If the logs are showing at the intended time, but the animation isn't behaving properly, it may be that the animation-triggering code itself needs tweaking. I'm not familiar enough with Tween to advise properly, but check that it doesn't need to be somehow "reset" in order to run multiple times.

  • I think I may need to set up a variable that can be switched back and forth in the action list. I set up a tween for when the menu is turned on and one for when it is turned off. I am turning the portrait on and off manually. The turn on animation works fine. The turn off animation triggers whenever someone else talks even if I don't tell it to turn off.
    This is my own fault for trying to add a little visual flourish, it works perfectly without the animation. I will let you know how I get on.
  • Alright, 90% of the way there. Triggering the turn menu off just poofs the portrait too quickly for the animation to show so I need a way to trigger it before the portrait is turned off. Does anyone have a link to details on reading a variable set in an action list in a script as I can't make heads or tails of the manual. Or is there a way of making the Turn Menu Off control run through the code before poofing things?

  • edited September 2022

    So...on the off chance it helps anyone. Please don't do what I did and spend 3 days trying to hard code a transition system that hooks into AC and realise that there is one already built in that handles both in and out transitions through the animator. screams internally and swears in Welsh You just need to make sure it has the 4 states it needs. On, Off, OnInstant and OffInstant and then it does the rest itself. Magic!
    I realise most people probably already knew this...but hopefully someone finds that useful.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.