Forum rules - please read before posting.

Possible bug: Uncompleted pathfinding survives scene changes

edited September 2019 in Technical Q&A

So this is a little odd, but I think there might be a bug concerning pathfinding and switching scenes. I'll try to explain the behaviour.

If I run an action Character: Move to Point with pathfinding, then switch to a new scene before the end point has reached, the character will be stuck on the previous path if returning to the previous scene. It appears that if the end point was never reached, this is remembered when reloading the scene, making the character stuck to this path that was never reached. It's probably possible to work around this, but wanted to let you know anyhow. I'm using Unity navigation, latest AC and Unity 2018.3.7.

EDIT: This is with Wait until finished turned off.

Comments

  • edited September 2019

    How are you switching scene, and what are your full "Scene loading" settings in the Settings Manager?

  • I use the Scene:Switch by name action to change scenes. Scene Loading is set to "Always reload..." and "Load Scenes asynch..." set to on.

  • I can't recreate such an issue - the player's Halt function is called by the SceneChanger script. Placing a Debug.Log statement in Halt can confirm/refute this on your end.

    What exactly is the behaviour you're getting? Are they not placed at the new scene's PlayerStart?

    When pathfinding, a blue line will show their intended path in the Scene window - is this showing up as the previous scene's path?

  • edited September 2019

    So after the player is moving along the path and the scene changes, when walk back to the other scene the player does not move to the PlayerStart marker. Instead, it is connected to the previous path and no matter what way you control the player, he follows the path back to the previous scene. What's strange is that this repeats when moving back and forth between the scenes, so the player is stuck on this path forever. The blue line shows up in the scene. I'll see if I can get a debug statement logged.

    EDIT: Halt function is called when the scene changes. When I turn on Wait until Finish on the Move to Point action, it works.

  • edited September 2019

    when walk back to the other scene

    Sorry, I'm not clear on this. This is only an issue when returning from scene B back to scene A? So going from A -> B initially causes no issue? But the "Move to Point" Action in question is in scene A?

    How does the player actually move between scenes? With Hotspots or Triggers? I suspect I'll need a test package to recreate this reliably.

  • edited September 2019

    Sorry for the confusing explanation.

    Yes, the problem occurs when returning back to scene A from scene B.

    When the player reaches a trigger, a Move to Point (run) with pathfinding action is run (Wait until finished not enabled). Next a camera fade action of 1 second, then a Switch Scene action. This works correctly.

    The Scene B loads and works correctly, but when walking back to the Scene A, the Player does not appear at the PlayerStart, but is stuck on the path used earlier. No matter which way you try to move the player, the player just sticks to the path. I'll see if I can create a test package, but it's a little bit of work to set up.

  • OK, I've kind of got a similar behaviour. The Player's path is surviving the scene change, but it doesn't prevent me from moving.

    I'll take it from here, but will report back if I need testing / more info.

  • I'm using the Direct Movement Method, Keyboard or Controller Input and Rewired plugin, by the way.

  • Good news is that this is fixed in the latest update... almost :)

    Character is not stuck to path when entering a new scene anymore, but I have a new issue: When the character comes from SceneA to SceneB and a Move to Point is run immidiately in SceneB, this just seems to skip. If I insert a Wait action of 0.1 seconds, the Move action works fine - so if this is not a reproducable bug it's probably possible to get around.

  • I'll attempt a recreation.

  • I have another issue with the character stuck on a path when a Move to Point action with Wait until finished is OFF. If the cutscene ends before the character has reached its point, the character will move towards that point no matter which direction you move him in. This is with direct control, latest AC and Unity 2018.3.7 PC. Is there a way to manually stop a Move to Point action? If that is the case, it's possible to work around it.

  • It seems it is possible to work around this issue by using a Move along path Action with the Stop Moving method if the cutscene ends before the player has reached its destination. Would love to get a fix for this if it's reproducable though!

  • From your description, I'm not sure that qualifies as a bug - you're issuing a movement command to the player that he then has to fulfill - cutscene or not.

    You could automate this behaviour, however, by hooking into the OnEnterGameState event so that you can stop the player's movement whenever you enter regular gameplay:

    using UnityEngine;
    using AC;
    
    public class StopPlayerAfterCutscene : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnEnterGameState += EnterGameState;
        }
    
        private void OnDisable ()
        {
            EventManager.OnEnterGameState -= EnterGameState;
        }
    
        private void EnterGameState (GameState _gameState)
        {
            if (_gameState == GameState.Normal)
                KickStarter.player.EndPath ();
        }
    
    }
    
  • Great, thanks!

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.