Skip to content

Centralize Player Aim Direction Calculation - #159

Open
Anand-Ramnarain-27 wants to merge 1 commit into
mainfrom
fix/pause-game
Open

Centralize Player Aim Direction Calculation#159
Anand-Ramnarain-27 wants to merge 1 commit into
mainfrom
fix/pause-game

Conversation

@Anand-Ramnarain-27

Copy link
Copy Markdown
Contributor

Summary

Simplified the aim direction calculation by using Input::getAimDirection() in both AbilityBase and PlayerTargetController.

  • Removed duplicated camera and look-axis aim calculations.
  • Both systems now get the owner's Transform and use the same centralized aim calculation.
  • Return Vector3::Zero if the owner's Transform is missing.
  • Removed the old fallback camera/axis normalization logic.
  • AbilityBase now passes the deadzone value to Input::getAimDirection().

Test Plan

  • Test keyboard + mouse aiming and make sure the aim direction is correct.
  • Test gamepad aiming and make sure it still works correctly.
  • Test abilities that use AbilityBase and confirm they aim correctly.
  • Test player targeting and make sure the target direction matches the player's aim.
  • Test around the deadzone to make sure the aim behaves correctly.
  • Make sure there are no issues when the owner's Transform is missing.

Replace duplicated camera- and look-axis-based aim calculations in AbilityBase and PlayerTargetController with a single call to Input::getAimDirection(ownerPosition, playerIndex[, deadzoneSq]). Both methods now fetch the owner's Transform and return Vector3::Zero if it's missing. Removes fallback camera/axis normalization and duplicated logic, centralizing aim computation and passing the deadzone from AbilityBase.

@AndreuMiroSabate AndreuMiroSabate left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It works as expected and I think avoiding this calculations would help with the optimization of the game.
Also testing the aim, I noticed that the aiming of the gamepad can be improved a little bit, because now it feels awkward selecting a target, like you need to aim directly to it. For me maybe we could change the system so when changing the target with the gamepad it selects the aimable object nearest to the direction aimed. But this is a thought that we will need to test more.
For the rest good job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants