Forum rules - please read before posting.

Bug (?) with Hotspots, Triggers, and Root Motion

Hey. I've participated in a game jam and noticed a strange (repeatable) occurence.

Our game has a climbing mechanic, which I made with a Hotspot and two custom Actions I yoinked somewhere from this forum, for enabling and disabling Root Motion. The hotspot enables root motion, plays the climbing animation (with "wait until finish" checked), then disables root motion. It also has a walk-to marker.

https://imgur.com/a/SNBPSCr

I noticed that there's a specific situation where I climb once or twice in a row (without letting go of W the entire time) and then walking into a trigger that has dialogue playing, the player is pushed back to the last used Walk-To marker. I can reproduce this consistently, as seen in the videos here.

I also noticed that this doesn't occur if I stop walking at least once before entering the trigger. It also doesn't occur when the trigger doesn't have dialogue in it. In the video below, I simply stop before the trigger, and the bug doesn't occur.

Other notes:

Unity 2021.3.11f1
AC 1.79.1
Player is using a Character Controller

Comments

  • edited December 2023

    Thanks for the report - though I'll need a few details to get to the bottom of it.

    Is this occuring specifically with dialogue, or merely if the ActionList blocks gameplay with e.g. an Engine: Wait Action?

    When the issue occurs, it looks like it's playing a jumping animation of some kind as the Player hops back. If you open up the Player's Animator controller at runtime, which animation is this, and how is the state of the controller different when it doesn't occur?

    Can you share your Player's Inspector, as well as the custom Action code, as well?

  • Just tested with an Engine: Wait (1s) and an Object: Transform (with 1s transition and "Wait until finish"), the bug occurs both times.

    For the animation, that wasn't jumping. It's still the base Locomotion blend tree (Idle>Run>Sprint), it just seems to "snap", probably because of the change in speed. In the player's animator at runtime, it goes directly from "Climb" to "Locomotion" and nowhere else.

    Here's my full player inspector:

    https://imgur.com/a/9frIoHG

    I don't know how to put code here without making the post too long so here's a wetransfer of the script files:

    https://we.tl/t-XvRuyeyMk7

  • Thanks for the details.

    If you're interested, the two Actions can be combined into one (below).

    Either way, if you can pause the game at the moment it occurs, check the Animator's Inspector. Does it show "Apply Root Motion" correctly unchecked?

    Try also inserting a Character: Move along path Action, with its Method set to Stop Moving, to halt the Player after disabling Root Motion. Does that prevent the issue?

    using UnityEngine;
    
    namespace AC
    {
    
        [System.Serializable]
        public class ActionRootMotion : Action
        {
    
            public bool state;
    
            public override ActionCategory Category { get { return ActionCategory.Custom; }}
            public override string Title { get { return "Root motion"; }}
            public override string Description { get { return "Enables/disables Root Motion."; }}
    
    
            public override float Run ()
            {
                KickStarter.player.GetAnimator ().applyRootMotion = state;
                return 0f;
            }
    
    
            public override void Skip ()
            {
                Run ();
            }
    
    
            #if UNITY_EDITOR
    
            public override void ShowGUI ()
            {
                state = UnityEditor.EditorGUILayout.Toggle ("State:", state);
            }
    
            #endif
    
        }
    
    }
    
  • Oh thank you for the script! It'll make things a bit easier in the future.

    The "Apply Root Motion" remains correctly unchecked the entire time after the last climb and during the bug.

    The Move along path action worked to stop the player, but only with "Stop instantly" checked. If unchecked, the bug still occurs.

    That makes the issue fixable in my game. But do tell if you'd like further testing, or maybe a package with my assets and animations.

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.