Forum rules - please read before posting.

Possible bug in Char.cs

I found an issue where every character reverts to it's default rotation before speaking.

I managed to find the issue in Char.cs,** line 3681**. What happens is, that the animation engine gets reseted even though it's not null. The second part of the if statement compares the type of animEngine, in my case 'Custom', and the name of the script. This condition can never be true. Commenting out this part fixes the issue.

/**
*

Gets the character's AnimEngine ScriptableObject.
* The character's AnimEngine ScriptableObject
*/
public AnimEngine GetAnimEngine ()
{
var test = animationEngine.ToString() + ")";
if (animEngine == null || !animEngine.ToString ().EndsWith (animationEngine.ToString () + ")")) //problem here
{
ResetAnimationEngine ();
}
return animEngine;
}

Comments

  • edited March 27

    What is your AC version number? This issue should already be addressed in the latest release.

  • edited March 27

    Sorry, forgot to add. It's v1.66.8.

    Something else: Every time I enter Play mode I receive this message for every character in the scene:
    "The character 'Character' has been temporarily upgraded - please exit Play mode and view their Inspector to upgrade permanently."
    Even after inspecting is it still shows up. Any idea?

  • Sorry, forgot to add. It's v1.66.8.

    My mistake - this will be fixed in v1.67.0.

    Even after inspecting is it still shows up. Any idea?

    In what version of Unity, and is this a prefab or a character in the scene?

  • Unity 2018.2.20f1.

    It is occuring for both in-scene characters and player prefabs.

  • Please try v1.67.0 - it's out now.

  • edited June 17

    @ChrisIceBox Just upgraded to AC v.1.68.1. Still getting both errors:

    The character XXX has been temporarily upgraded - please exit Play mode and view their Inspector to upgrade permanently

    on starting play mode - and the animationEngine being reseted every frame when character inspected.

    !animEngine.ToString ().EndsWith (animationEngine.ToString () + ")")

    where animEngine is the name of the script and animationEngine is "Custom". So this will never be true.

    Unity version is 2019.1.4.

  • edited June 18

    Quite right, apologies.

    What is the effect of replacing the contents of Char.cs' GetAnimEngine() method with the following?

    if (animEngine == null)
    {
        ResetAnimationEngine ();
    }
    else
    {
        if (animationEngine == AnimationEngine.Custom && !string.IsNullOrEmpty (customAnimationClass))
        {
            // OK
        }
        else if (animationEngine != AnimationEngine.Custom && animEngine.ToString ().EndsWith (animationEngine.ToString () + ")"))
        {
            // OK
        }
        else
        {
            ResetAnimationEngine ();
        }
    }
    return animEngine;
    
  • edited June 18

    This does the trick, thanks. ResetAnimationEngine() now gets called only after exiting play mode ( animationEngine == null ), which is probably intended.

    Any idea about the "The character XXX has been temporarily upgraded " message? It's probably nothing serious but still annoying to see in the console every time I enter play mode.

  • What is the full error message, stacktrace included?

    Viewing the Inspector outside of runtime should be enough to upgrade it - but if you have a custom animation engine, that may not hold true.

    Try exiting play mode, temporarily switching to Sprites Unity, then switching back. Does that resolve it?

  • Switching to SpritesUnity and back to custom resolves this issue, fantastic!

    While on the topic of animation engines: Which engine should I use in case I just need a NPC reference and no actual animations?
    Example: A scene has a radio playing a speech and to add speech bubbles over the radio I have to add the NPC script with a dummy animator controller.Because of that I am constantly getting alerts because of the empty animator. Is there a trick to this? Not sure if other games have such scenarios or not, but adding an "empty" animation engine would maybe be useful for some cases, or even for testing purposes only.

  • You could certainly implement a new subclass of "AnimEngine" with no overrides. However, even with e.g. the Mecanim engine, an Animator is not necessary - so long as you don't declare any parameters. Leaving all the e.g. "Move speed float" fields empty does away with the need for an Animator to actually be present.

  • Alright, thanks!

  • edited July 9

    Hey there!
    Not sure how I didn't see this sooner but the code you provided for GetAnimeEngine() doesn't work quite well. The problem I see is that if I set a custom animEngine **it won't call **ResetAnimationEngine() because the if statements are not correct. I think it should compare animEngine.ToString() with customAnimationClass and if it's not equal reset the engine.
    This worked for me:

    public AnimEngine GetAnimEngine ()
    {
    if (animEngine == null)
    {
    ResetAnimationEngine();
    }
    else
    {
    if (animationEngine == AnimationEngine.Custom && animEngine.ToString().EndsWith(customAnimationClass + ")"))
    {
    // OK
    }
    else
    {
    ResetAnimationEngine();
    }
    }
    return animEngine;
    }

  • Thanks for the feedback.

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.
Do NOT follow this link or you will be banned from the site!