Forum rules - please read before posting.

Switching from point-and-click to direct input in-game breaks movement

I'm trying to troubleshoot a very strange issue. I have an option in-game that switches from point-and-click movement to direct movement but doing this reliably breaks character movement. The character appears to be walking in place and I can rotate them but they stay rooted to the spot. If I begin the game with direct movement enabled I can move fine, switch to point and click and move fine, then switch back to direct and everything works normally! It's 100% consistent.

My game is 3D using unity navmesh with a rigidbody on the character. Ignore gravity, freeze rigidbody when idle, move with rigidbody. I've discovered a workaround that seems to work so far where I add a wait of .1 seconds during my start game action list before it changes the movement method but I'd like to nip this in the bud in case it becomes a problem down the line. This might be the actual solution, like maybe the rapid change in movement method is missing an update or something and I need to call it a frame later, but it's so weird it breaks one way but not the other.

Comments

  • I'm not able to recreate the issue so far - I'll need a few more details.

    • What are your AC/Unity versions?
    • Are any custom scripts involved?
    • Does the Player rely on root motion?
    • Is that character pathfinding at the time of the switch to Direct?
    • What is the effect of running a Character: Move along path Action, passing in the Stop Moving command, after switching to Direct?
    • Does it work if you instead manually change the Movement method in the Settings Manager?
  • AC 1.78.4
    Unity 2019.4.40f1

    Custom scripts
    I'm using the new input system with the integrated package from the Wiki. I modified it a bit to change hotspot detection from mouse over to direct control when input changes and turns on all direct control in the menu manager. I do use a custom event system but it's just what I've picked up from forum posts to integrate input switching smoothly.

    Animation offset which randomly assigns an offset float to an animator

    I have the setup options from the resolution detecting tutorial on the website

    That's everything I can think of. Nothing that influences navmesh or pathfinding.


    Root motion is off.

    During my tests I ensure the player is stationary. If I begin pathfinding and switch to direct control I notice the rigidbody maintains the pathfinding velocity which messes things up. I've experimented passing the "stop moving" action on switching over which stops the above velocity issue but the character is still rooted in place.

    I can change the movement in the settings manager but the rooted-in-place issue persists.


    Something I just tried: I created a marker and a move-to-point script. My character is stuck walking in place, I ran the script, he turns to walk towards the point but is rooted in place. I pause the game bringing up the pause menu, unpause, and he teleports to the marker as if completing movement but is still rooted to the spot! I tried teleporting them and recalculating pathfinding but no joy.


    So I think the issue lies in pathfinding. I turned off navmeshagent integration, it appears to work 100%, then I left integration on and turned off unity's nav mesh agent and it appears to work 100%. Am I being a dummy by having both components active? It is strange point-and-click input has worked consistently without issue for years with the two scripts attached and only when I implement an option to switch does it break.

    Secondary question, how do I have finer control on character rotations e.g. standing at a diagonal? My character always faces whatever direction is pressed and they seem to only turn in the four cardinal directions. Is this something I have to tweak in the controller input?

    Attached are screenshots of my components.


  • edited October 2023

    I spoke too soon. NavMeshAgent Integration causes the problem about 50/50. Nav Mesh Agent alone appears flawless.

    An interesting note: switching inputs turns on navmeshagent integration on the prefab character in the Resources folder and sure enough when I run test play again it breaks. I've removed the component completely and everything seems good to go for now I but I haven't stress tested yet.

  • Thanks for the details - indeed, it's down to the NavMesh Agent Integration component.

    A fix for this is already set to be included in the v1.79.0 release. In the meantime, you should be able to address it by opening NavMeshAgentIntegration.cs, making "disableDuringGameplay" public, and removing the code in Start that sets its value automatically.

  • edited October 2023

    That resolved the movement issue, thank you, but now I can't use the "move to point" action without the same thing happening. This one is very strange it's difficult for me to explain.

    Absolutely no issues with moving to hotspot markers. I click on a hotspot and without issue I move to the marker. The problem comes with Move to point where the active player has to pathfind to a marker. If I set "wait until finish" they get stuck in place.

    Caveat: if I run the action they walk in place until I stop the action and they complete the movement. If I uncheck wait until finish they complete the movement but then I need to calculate a wait time to freeze gameplay to sync things up.

    For the time being I'm probably just going to disable integration and work with navmesh. I prefer the feel of AC integration but I'm up against a deadline.

    edit: oof, no, the AC system is just too integral to the game feeling good to play lol. And now something is funky with the triggers where they aren't triggering by the player transform or rigidbody when pathfinding. Oh well, back to the grind.

  • The problem comes with Move to point where the active player has to pathfind to a marker. If I set "wait until finish" they get stuck in place.

    Is the "Movement method" stil a factor here?

    Can you share screenshots of your Player's full root Inspector - both in Edit mode, and at the moment the issue occurs?

    Also at this time, does the Console report anything - and does the Scene window show the "blue line" indicating the intended destination?

  • I had to revert to my original build and just take things step by step. Updated Adventure Creator to the latest (august 30th as of this writing) build. Good. Added the new Unity input package and AC helper package for the new input system. Good. Did some tweaks to the AC navmesh integration component and uh-oh, my character is walking in place as he never completes his pathfinding with point-and-click movement unless I order him to run (while walking in place the blue-debug-line is visible but it's like the actor just can't move to the navpoint at walking speed). But I overwrite the prefab with one from an older build and right now I have the mouse and keyboard inputs working exactly as I want them.

    I can consistently recreate this in a clean install of AC in a new project with the Tinpot character, removing the player controller, adding a rigidbody, and navmeshagent integration with "disable during gameplay" unchecked, and movement mode direct input keyboard. I'm going to experiment with the move character action to check the movement method and turn off/on disable during gameplay accordingly.

  • Thanks for the details - though I can't recreate the behaviour.

    Let's make sure we're working with the same tweaks to NavMeshAgentIntegration - I'll PM you a link to the updated one.

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.