Skip to content

fix: Rogue dashing on pillars and out of bounds #543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from

Conversation

fernando-cortez
Copy link
Collaborator

@fernando-cortez fernando-cortez commented Mar 11, 2022

Description (*)

This is a pathfinding solution that ties player navigation more rigidly with the navigation mesh generated.

A significant change here is the re-layering of Dungeon prefabs. A Environment layer has been introduced to distinguish between Ground vs Environment (non-interactive) level prefabs.

Navigation is only successful when any "Ground"-tagged object is intersected via raycast, as well as when the intersection point is a valid point on the generated nav mesh. This eliminates any teleports to the tops of any ground colliders, since the point of interest will always be on the navmesh floor.

While testing, it was also discovered that the rogue could dash outside the level. If there was any part of the navmesh that bled outside the bounds of the level (very few cases), the dash could travel to that point.

To combat this, a minor tweak was added to DynamicNavPath which eliminates appending the last point to the nav path (since this point could actually be out of bounds).

A last added bonus from this PR is that the rogue no longer goes through the door, since the visibility check inside ActionUtils now uses the Environment layer as a blocking layer (as well as for the mage shot).

Related Pull Requests

This is work on top of PR 542

Issue Number(s) (*)

Fixes issue(s): MTT-2412

Manual testing scenarios

  1. Select the rogue.
  2. Pick a point on top of a pillar or out of bounds.
  3. Press dash action.
  4. Rogue will travel to the last point inside the level before the spot chosen.

Questions or comments

I'm thinking this might not be a workaround. I think it does make sense for navigation to be directly linked to the nav mesh.

Another comment here is that ClientInputSender is beginning to become too much of a god class. This needs to be broken down to only process input and publish results to listeners.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@fernando-cortez fernando-cortez added 1-Needs Review PR needs attention from the assignee and reviewers GDC-cherrypick labels Mar 11, 2022
Copy link
Contributor

@LPLafontaineB LPLafontaineB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, except a small bug. We can no longer click in the area near the chest.
image
Will approve once fixed

@fernando-cortez
Copy link
Collaborator Author

Looks good to me, except a small bug. We can no longer click in the area near the chest.

Right, that bit is elevated. I'll likely end up modifying layer matrix then to properly fix this.

if (Physics.RaycastNonAlloc(ray, k_CachedHit, k_MouseInputRaycastDistance, k_GroundLayerMask) > 0)

// clear previous results
for (int i = 0; i < k_CachedHit.Length; i++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this step? Why not just rely on the count returned by RaycastNonAlloc?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the array always guaranteed to be populated orderly? I was wanting to access elements within the array, but that could simplify the iteration.

However, I'm revisiting this atm, so this may end up reworked. I think layers will be the cleanest fix (though it will affect prefabs and potentially some gameplay scripts).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the example here https://docs.unity3d.com/ScriptReference/Physics.RaycastNonAlloc.html
you want to use non-alloc for perf reasons, it wouldn't be super performant to have to access all elements to check if they are null :P

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's since been reworked and optimized.

@SamuelBellomo SamuelBellomo added 2-Reviewed with Comments PR requires owner's attention and removed 1-Needs Review PR needs attention from the assignee and reviewers labels Mar 11, 2022
@fernando-cortez fernando-cortez force-pushed the fix/nav-mesh-floaters-removed branch from 24c0500 to 56df969 Compare March 11, 2022 20:01
Base automatically changed from fix/nav-mesh-floaters-removed to release/GDC2022 March 11, 2022 20:20
@fernando-cortez fernando-cortez added 1-Needs Review PR needs attention from the assignee and reviewers and removed 2-Reviewed with Comments PR requires owner's attention labels Mar 15, 2022
LPLafontaineB
LPLafontaineB previously approved these changes Mar 15, 2022
@fernando-cortez fernando-cortez added 4-On Hold PR can't proceed because it's blocked or is otherwise waiting on something. and removed GDC-cherrypick labels Mar 15, 2022
@fernando-cortez
Copy link
Collaborator Author

Placed on hold as this will target develop instead.

@fernando-cortez
Copy link
Collaborator Author

Closing as this has been reworked to target develop here.

@fernando-cortez fernando-cortez deleted the fix/rogue-dashing-on-pillars branch May 4, 2022 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-Needs Review PR needs attention from the assignee and reviewers 4-On Hold PR can't proceed because it's blocked or is otherwise waiting on something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants