Forum rules - please read before posting.

Clicking Nav Mesh in other rooms.

edited August 2016 in Technical Q&A
Hello everyone,

I am using point and click in a 3D game with unity navigation. I have a building with some small rooms and I am finding that when clicking on walls the character leaves the room and tries to walk to the other side of the wall. This is obviously not what I want.

I think the problem is that the character cant get to the point I'm clicking within the room, so he is leaving the room to try and get there some other way. 

I searched the forums and found a topic on this and the advice was to ensure the colliders were on the NavMesh layer, which they are.

It's very important that I fix this as the way I am dealing with rooms is via hotspots to walk to a marker and change the camera, so if the player leaves the room without using the hotspot (they can't usually click outside the room so they shouldn't be able to) the camera will not change and the player wont know where they are.

I'm thinking about solving this somehow via navmesh obstacles that appear in doorways when you enter a room however this is adding another layer of faff. I just wondered if anyone could think of an easier solution.

Ideally I would like clicking on the colliders I'm using for walls to have no effect what so ever and they just block anything clicking behind them (if they are on the navmesh layer the character walks towards them when they are clicked). I've considered creating a giant blank hotspot to achieve this but again it is a faff. 

Could I create some kind of layer that just blocks clicks?

Thanks in advance. 

Comments

  • edited August 2016
    Screenshots or videos that illustrate the problem will be necessary here.

    Placing your "blocking" colliders on the NavMesh layer should indeed prevent the player from moving to the next room - though they will still cause the player to move to the point on the NavMesh that's closest to the click.  If the collider is closest to the correct side of the NavMesh it should still mean that the player doesn't leave the room.

    It may be worth considering the use of Mesh Collider navigation for this particular scene, as this allows for pre-determined NavMesh shapes to be swapped in and out as required.  With this method, you could split your rooms up with their own NavMeshes, so that you can't navigate from one to the other without the active NavMesh being explicitly changed.
  • I can't really use mesh collider navigation as I am putting my scenes together in Unity so I couldn't easily model a mesh the same size in a 3D package. 

    I've drawn a picture as I can't access my project from where I am.

    image
    The X is where I click and the line is the route the character takes, the blue bit is the nav mesh. It cannot get to that point inside the room as there is an object in the way so I think it's deciding the other side of the wall is the closest point. 
  • Try moving the wall's collider closer to the inside of the room.  You can use a separate Trigger collider to block NavMesh clicks to any other your game may use.

    It may also be worth removing the NavMesh in the doorway, so that the inner and outer rooms are isolated - you could then move the Player along a pre-set Path when you want to move between them, to avoid pathfinding.

    A Mesh Collider would still be something to consider.  It would require back-and-forth to get the shape correct, but it would give the best result.
  • Thanks for the continued help.

    I'm not sure what you mean by a Trigger Collider? Just a trigger that you make with AC? I tried putting one of those in front of the wall and it didn't seem to have any effect. 
  • I meant your Collider that covers the wall, which should be on the NavMesh layer.  You can check "Is Trigger" on it to prevent physical collisions taking place - sorry for the confusion, it's not to do with AC's Trigger prefab.
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.