Forum rules - please read before posting.

Navigation Issues

Dear Chris, long time not hear...
After ENCODYA, I'm now working on two games that use AC.
For one of those, I'm having issues with navigation.
Unity version: 2021.1.3
AC version 1.74.5
So, first of all, the game is a mix of 2D and 3D, a side scroller where player moves only along X axis, but on a 3D environment. I using this script: https://adventure-creator.fandom.com/wiki/2D_point_and_click_along_one_axis
But my camera perspective is to 3D, otherwise it doesn't work.
I'm using both Direct Movement and Point and Click movement, optionable for the player (either using controller or keyboard+mouse).
My player has a BoxCollider2D and RigidBody2D (this creates some warnings, but it works nevertheless), I then have a narrow NavMesh.
I've a couple of issues while using the "PnC movement" (all is good on Direct Movement).

The first issue I'm having is that sometime (I'd say 20% of the cases) my click doesn't move the character, but if I move the mouse just a few pixels away from that not-working click, then it works (so it's not related with something blocking the raycast in the area, since trying again a click a tad on the left or on the right, it works). Any idea of what it could be? The NavMesh search is set to 0.9 (which I guess it's 90% of the screen) and the direction to "Radially Outwards from Cursor". So basically I should be quite safe on my clicks on screen to catch a NavMesh and move the player in that direction, and yet, many times the click doesn't return anything. (p.s. Destination Accuracy is set to 1, Pathfinding Update to 0.1)

The second issue is related with a volumetric fog I'm using in one scene. This fog has a box collider covering basically the whole scene, and therefore blocking my mouse clicks. I cannot change the layer of the fog to "Ignore Raycast", because to work it needs to be in its own layer "FogVolume" (and even if I change it, the script it's automatically setting it to FogVolume... it's a third party script, which will be too complicated to change). So, I wonder, can I tell AC somehow to ignore raycasts on both IgnoreRaycast and FogVolume layers? Maybe extending some AC class? Or attaching a script to the GameEngine? Any hint in this sense will be very appreciated.

Thanks a lot!
Nicola

Comments

  • edited November 2022

    P.S. I also get often the "Invalid node target - cannot update pathfinding on Protagonist" (this when the click works, and the protagonist is moving to a marker, it gets stuck on the Walking animation until next click... again, not always... maybe 5% of the cases)

    P.P.S. the issues above happens when "Unity UI blocks movements" is NOT ticked.

  • I will need to know more about the way your game is set up. Is it technically a 2D or a 3D game, putting the art aside?

    Are you using 2D or a 3D NavMesh? Screenshots will help convey this, please.

    Pointing-and-clicking should not be blocked by Colliders on an undefined layer.

  • It's a 3D game with 2D sprites, with movements only on X axis. Unfortunately I cannot share publicly game screenshots or videos due to NDA (I might send you a PM though), but this is a scene setup from Unity: NavMeshSettings (the actual game won't have this view, but a perfectly side camera). So everything is handled as a 3D game even if it looks like a sidescroller 2D: the NavMesh is a very narrow 3D plan (voxel size doesn't give any warnings), Camera Perspective is set to be a 3D camera, characters however, use BoxCollider2D and RigidBody2D (p.s. I've tried putting BoxCollider and RigidBody -3D- but the issues were still there, so for other technical reasons I prefer to keep my characters with BoxCollider2D and RigidBody2D).

    Here are some of the manager and player settings:
    Manager and Player Settings

    (note that the issue is present even with "Unity UI blocks interaction and movement" is un-ticked)
    (note that my "AnimEngine_SpritesDS" on Player Anim settings is a simple script that overrides just AnimEngine_SpritesUnity PlayIdle() if a Dialogue System conversation is active)

    It's strange that you said "Pointing-and-clicking should not be blocked by Colliders on an undefined layer." because the behaviour I notice with the fog collider, is that it works when the fog is disabled and it doesn't when the fog is on, as if it is indeed the fog blocking my point-and-click. I've also tried creating a big dummy collider cube covering the whole scene, on Default layer, and the click wasn't working (maybe because Default is reserved for hotspots). I set this big dummy cube layer to "Ignore Raycast" and the point and click worked. I changed again layer of the big dummy box to "FogVolume" and clicking doesn't work... That's why I was wondering if I can assign more layers on the Raycast Settings/Deactivated layer.

    Anyway, they are two different issues (actually 3, considering I also get often - but not always - the "Invalid node target - cannot update pathfinding on Protagonist" error).

    So, to summarize, my issues are three:
    1- 20% of my clicks on whatever scene don't move the character (but if I move slightly the mouse and click again it works as if there isn't really something catching my cursor)
    2- when I've a box collider covering the whole scene on a "FogVolume" layer, 100% of my clicks don't work.
    3- 5% of my character movements return a "Invalid node target - cannot update pathfinding on Protagonist" error, with the character stuck in the Walking animation when reaching a node, until the next click.

  • for other technical reasons I prefer to keep my characters with BoxCollider2D and RigidBody2D).

    2D components will have no bearing in a 3D world. If you require your characters to react properly to a 3D scene, they will need to have 3D components.

    Neither a collider nor rigidbody is technically required for an AC character, however, but you won't have physics/collision/gravity effects.

    (note that the issue is present even with "Unity UI blocks interaction and movement" is un-ticked)

    This option only refers to Unity UI - a 3D fog collider won't be affected by this.

    20% of my clicks on whatever scene don't move the character (but if I move slightly the mouse and click again it works as if there isn't really something catching my cursor)

    Is the minimum distance between the click and the character a factor?

    Your NavMeshSettings screenshot doesn't reveal what Navigation method you're using. Are you baking your NavMesh using Unity's Navigation tab?

    Try enabling Retro-style movement? in your character's Inspector.

    when I've a box collider covering the whole scene on a "FogVolume" layer, 100% of my clicks don't work.

    I cannot recreate such behaviour. Is the camera inside the volume, and - if so - does it work if you move the volume such that it's in front of the camera?

    5% of my character movements return a "Invalid node target - cannot update pathfinding on Protagonist" error, with the character stuck in the Walking animation when reaching a node, until the next click.

    I'll need those details on how your navigation is set up.

  • edited November 2022

    Thanks for your reply Chris. So...

    2D components will have no bearing in a 3D world. If you require your characters to react properly to a 3D scene, they will need to have 3D components.

    I don't need my characters to react to a 3D world, that's why I'm handling them with Collider and RigidBody in 2D. I then have Triggers and such in 2D to react with them, but hotspots are in 3D. So all in all it works good in this sense, but I was wondering if it impacts the navigation. Even if I made some tests also attaching to my player 3D collider/rigidbody and it didn't change much the behavior.

    Is the minimum distance between the click and the character a factor?

    Not really.

    Your NavMeshSettings screenshot doesn't reveal what Navigation method you're using. Are you baking your NavMesh using Unity's Navigation tab?

    Pathfinding method is "Unity Navigation", the NavMesh is correctly baked (under Navigation panel I can see it in blue and with correct values/shape). The NavMesh is on a NavMesh layer, and it's "Navigation Static". By the way, the NavMesh is just a basic Unity plane with scale values to make it narrow, attached there's a Mesh Collider (non convex). I don't have NavMeshAgent nor NavMeshAgentIntegration (but I can try to play around with them).

    Try enabling Retro-style movement? in your character's Inspector.

    The retro style movement is enabled on my character. Do you mean to disable it and give it a try? Anyway, I've tried, and the issue is not solved (and other glitches are happening when disabled, so I'll keep it enabled).

    I cannot recreate such behaviour. Is the camera inside the volume, and - if so - does it work if you move the volume such that it's in front of the camera?

    The volume is in front of the camera, covering the whole scene, but the camera is outside of it. By the way I'm using "GameCamera" script + "MainCamera" one. If I increase the volume size to include the camera, the problem is not there. So somehow the issue is if the whole volume is in front of the camera.

    I'll need those details on how your navigation is set up.

    You mean the Pathfinding Method? (which is "Unity Navigation") and the fact that the NavMesh is baked? Or are there other settings beside those and the ones on the screenshot I posted earlier that you'd like to check?

    Question: is there a way to have some sort of debug? Like a script to attach somewhere that returns debug.log at mouse click? Telling what has been clicked in scene, including EVERYTHING (so not only hotspots). This might help figure out the first two issues (fog and navigation not always responding). Regarding the third issue (Invalid Pathfinding Node), I've no clues.

    What drives me insane is that 80% of the cases the point and click works... It would have been easier to debug if it was a 100% yes/ 100% no.

    P.S. if it could help, I'm using third parties, such as Rewired and Dialogue System, but I've tried to disable them and the issue was still there.

    Thanks a lot for your time! Truly appreciated!!! If we can't find a way out, I might send you a PM with more detailed videos.

  • Have you modified the PointClickHorizontal2D wiki script? That will remove Y-positional changes to the character, whereas a 3D world will need the Z-axis affected instead.

    Your setup is too unique for me to give more specific advice. You will need to PM me a test scene, along with instructions, that I can use to experience the issues for myself

  • No, I haven't modified that script. It is exactly in the wiki link I posted on my very first message. Also, fun fact: I don't see big changes with that script active or not, as if it's maybe not working properly? Is it updated?

    Nevertheless, I understand is very hard to help me this way, so later today I will try to recreate my game setup on a new AC project, using mostly the AC demo assets, and send you a Unity package with the scene.

    Thanks.

  • Also, fun fact: I don't see big changes with that script active or not, as if it's maybe not working properly?

    As I said, it's intended for 2D games and will update the Y-position. It won't have an effect in a flat 3D world.

  • Sorry, I misunderstood that message. Nevertheless, yesterday I sent you a PM with a testing scene. Have you received it?

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.