Forum rules - please read before posting.

Physics bug when running between scenes

OK, this is a weird one. When holding down the running button while moving between scenes, the physics go heywire when entering a trigger. I've tried to capture the bug on video here:

https://imgur.com/a/yvjASkD

If I release the running button at any point before the player hits a trigger, everything is normal. I'm using latest AC in Unity 2018.4.12f1, using Direct Control. Any ideas what to look for here?

Physics settings for character:
https://imgur.com/a/OP6XNsB

Comments

  • Does it occur when using a Character Controller instead of a Rigidbody / Capsule Collider combo?

    I'm not entirely clear what's going on in the video. Is the Player moving erratically before or after the scene change?

    Seeing the video with Gizmos may reveal more. I can't tell what the Player may be encountering to make him move like that.

    I can't recreate such an issue with e.g. Tin Pot and a standard 3D Settings Manager.

  • edited November 2019

    I tried changing to a Character Controller, the behaviour is the same.

    Here is a video with gizmos:
    https://imgur.com/a/rHM1rEQ

    As you can see, the erratic running is when (trying to) entering a trigger. This only happens when coming from a previous scene, while holding the run button. As the character enters the new scene an actionlists run where he walks to a marker. While holding the run button, it appears as if the character wants to jump back to this marker even after he has reached this. Just a guess from me is that there is something strange happening with the path and/or marker while running. Could this be a side effect of your fix of character input not registering when loading a scene?

    EDIT: This is with Attempt to be super-accurate is ON. When OFF, this bug disappears! However, I really want the accuracy of this setting, as otherwise characters are off position in important cutscenes.

  • Could this be a side effect of your fix of character input not registering when loading a scene?

    Did this only start occuring after the fix was implemented?

    I'll attempt a recreation. Where is the Player and Marker in relation to the Trigger? Are both outside of it at the time the scene-switch occurs?

  • I don't know when this started occuring, but since running between scenes was not working before I hadn't noticed it.
    In this scene, the character starts at a playerStart at the bottom of the screen and runs to a marker just up the road (0:27 in the video). When holding down the controls for running while this actionlist is running (and super-accurate is ON), it appears that the character never quite reached their intentional marker, and therefore it bugs out when running into a trigger. I noticed the same bug in another scene where the character is running towards a marker, while keeping the run button down.

    I'll try to keep super-accurate OFF for the time being, as this makes this bug go away.

  • I can't recreate this issue - it sounds like the situation is very specific.

    If you can create a test package that clears demos the issue, I can take a look at it - but otherwise I'm not sure what else I can suggest.

  • Just an update on this, I needed to go back to super-accurate ON to keep characters ending up at exactly the right spot. But a workaround is that I use a Character Move Along Path: Stop Moving (Instantly) action after the Move to Point Action. It appears that this prevents the bug where the character doesn't quite reach the end marker while holding the running button in a cutscene from happening.

  • Sorry for bringing back an old issue, but I wonder if there's an easier way to fix this other than adding Stop moving Instantly actions to every Move to Point action?

    I believe this happens when the player moves to a point with "Super-accurate" enabled in a cutscene. When running or walking away from that point, it appears like the end point of the path was never truly reached, and the player jumps erratically towards that point - as long as you held the direction stick while the cutscene was playing.

    I tried changing movement to Retro-style, and while this made this issue go away, the pathfinding was not as good and the character ended up stuck in the terrain if the walkmesh had corners.

    I'm using latest AC and Unity 2018.4.18.

  • I'm afraid I have to refer you to my earlier post. It's not something I can recreate - but if you can PM me a test package that demonstrates the issue, I'll certainly investigate.

  • Thanks, I'll investigate some more and see if I can create a package that isn't too huge. It appears that the issue is more prominent with triggers that Pause Gameplay, so I'll dive down the rabbithole and see if I can see any patterns :)

  • Sorry for the necromancy, but I'm in the very final stages of development and have discovered that I still have som issues with "Super-accurate" and Pause Gameplay triggers in my game. I'm aware that this is probably very specific to my setup of character speed/controller/pathfinding etc, but I think I've found a dirty hack/workaround.

    So the issue is that when moving to a marker - for instance when clicking on a hotspot - if the player immediately runs away after finishing the interaction and hits a trigger set to Pause Gameplay, the player jerks back towards the endpoint of the previous path/marker.

    If the trigger is set to Run in Background, this doesn't happen (at least not in my experience), but if I add a "Stop moving instantly" action on the top of the trigger's actionlist, the jerky jump is prevented. I ended up editing AC_trigger.cs around line 326:

    case TriggerDetects.Player:
                    if (KickStarter.player != null && obToCheck == KickStarter.player.gameObject)
                    {
                        //jump fix
                        if (actionListType == ActionListType.PauseGameplay)
                        {
                            KickStarter.player.Halt();
                        }
                        return true;
    
                    }
                    break;
    

    Testing this seems to have the same effect as inserting a Stop moving action, does anyone see any other pitfalls doing it like this?

  • And a follow-up (Not sure if this should be a separate thread) - when a player is moving towards a marker in an actionlist, where exactly is this pathfinding code? I wonder if I could force a KickStarter.player.Halt(); when the end of the path is reached. Does it use the ActionCharPathFind.cs or some other code?

  • the player jerks back towards the endpoint of the previous path/marker

    What's the actual behaviour - are they teleporting? Try placing some Debug.Log statements in the Char script's Teleport or Halt functions - if they're called at this time, the stacktrace should reveal the cause.

    does anyone see any other pitfalls doing it like this?

    A non-invasive method would be to hook into the OnRunTrigger custom event, which would have the added benefit of being able to have it only occur for specific Triggers, if that was desired:

    using UnityEngine;
    using AC;
    
    public class TriggerHalter : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnRunTrigger += OnRunTrigger; }
        private void OnDisable () { EventManager.OnRunTrigger -= OnRunTrigger; }
    
        private void OnRunTrigger (AC_Trigger trigger, GameObject collidingObject)
        {
            KickStarter.player.Halt ();
        }
    }
    

    when a player is moving towards a marker in an actionlist, where exactly is this pathfinding code? I wonder if I could force a KickStarter.player.Halt(); when the end of the path is reached.

    ActionCharPathFind will generate an initial list of points, but the processing of it (and updating of it, if necessary) is handled in Char.

    But to run code when a character stops on a path, you can similarly hook into the OnCharacterEndPath event:

    using UnityEngine;
    using AC;
    
    public class HaltPlayer : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnCharacterEndPath += OnEndPath; }
        private void OnDisable () { EventManager.OnCharacterEndPath -= OnEndPath; }
    
        private void OnEndPath (Char character, Paths path)
        {
            if (character == KickStarter.player)
            {
                character.Halt ();
            }
        }
    
    }
    
  • Thanks for the detailed answers!

    The behaviour is the same as the example videos in the previous posts. The player rapidly jerks back towards the last marker/end of path.

    I added Debug.Logs to teleport and halt in char.cs.

    I removed my previous AC_trigger.cs fix and added the HaltPlayer script you detailed to the player. This seems to have done the trick! With this script active on the player, the jerky movement is gone when running into a trigger directly after a move to marker action! It is much better to halt the player like this, on the OnEndPath instead of inside the AC_trigger - since that made the character stop for a brief moment while running through a trigger.

    I will playtest some more, but this looks like a promising fix :)

  • I added Debug.Logs to teleport and halt in char.cs.

    Any leads with this? Though it's still not an issue I can recreate, I should like to address it if it is an AC bug.

  • I have to do some more testing, I didn't have the time to dive in right now - it's deadline time. Hopefully I'll be able to revisit this afterwards (and make a test package). But the halt script removed the issue on both PC and Switch.

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.