Forum rules - please read before posting.

Block user clicks on part of a walkable area

I'm using mesh collider pathfinding and it works great but on a couple of occasions I've needed to block an area of my mesh collider from user clicks (to stop the character from suddenly walking off in the opposite direction and trying to path find round to the other side of a gate for example.

I notice the tooltip for a collision cube (the blue one) says "blocks character movement as well as cursor clicks if placed on the default layer" .. I understand that as I'm using mesh collider pathfinding it wont block character movement but does that also mean it doesn't block cursor clicks, as it just doesn't seem to ever block my clicks on a navigation mesh?

Is there a consistent way to block any clicks on a navigation mesh, by positioning a box collider in the line of sight (from your current camera) or is the best practice just to make lots of smaller navigation meshes and switch between them as you transition to different cameras in the same scene?

Thanks in advance.

Comments

  • edited December 2020

    A Collider on the Default layer should block point-and-click raycasts, but AC will try to find an alternative click point if the one directly under the mouse fails.

    The exact behaviour is set in the Settings Manager's "Movement settings" panel - particularly NavMesh search direction field. Set this to Straight Down From Cursor if you want clicks made on the Collider to be treated as clicks on the ground in front of it.

    Though, where visable, I do recommend having your NavMesh properly describe the walkable area - as opposed to manually blocking parts of it off. This needn't be a case of breaking it up in to smaller NavMeshes, but having separate NavMeshes depending on situation (i.e. one with both areas accessible when the gate is open, another with only one side accessible when the gate is shut). The 3D Demo uses this technique to swap out the NavMesh when the barrel is pushing into the middle of the scene.

  • Not sure if this might help but anyway.
    Is it 2d? Try to create dummy hotspots with colliders that stand out on higher layer order or Z position than your walkable clickable area to block clicks.

  • edited January 2021

    Thanks for the tips, @SkyTree I'm currently working on a 3D game but thanks for the 2D tip, it will be useful when I start on a 2D one.

    Part of my issue is wanting to include interesting cinematic camera angles which sometimes allow a user to try and click on something in the foreground and accidentally click a point on a navmesh in the distance or behind the building in the foreground.

    A combination of choosing better camera angles and trying some of these options out should work.. weirdly in the same scene I use a collider on the default layer to do this exact job, but from a different camera at a much higher camera angle, the same collider settings seem not to work.

    For the time being I've just changed the Camera angle but I will report back once I've tried your suggestion Chris.

    Many 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.