AimGuide
The AimGuide is a component of the player used in conjunction with ranged weapon, to handle aim preview.
Goals
- Draw a preview of where the player is aiming at.
- Handle aim assist detection.
How it works
The AimGuide has one public method called get_aim_assisted_position_for
. Any ranged weapon can call this function passing the vector of the target's global position and a max length that should be the max range.
The AimGuide will first check if it finds anything to collide in that direction so that it can lock into it, and return the final vector any ranged attack/weapon/projectile should use. The AimGuide will already limit this final position to the max length passed in, and update the aim preview to this "assisted" position. If it doesn't find anything to lock on, it will just update the aim preview and return the vector it received.
Setting up AimAssistAreas
Anything that should be "locked on" by ranged weapons should have a AimAssistArea
node. Just create this node from the Add Node interface and it will already come configured with the correct physics layers.
Add a collision shape to it, it should be as big as you want it to be easy for the aim assist to lock into this entity. In the editor, select the path to the collision shape or polygon of the HurtBox for this entity. The AimAssistArea will redirect the aim to the position of the collision of the HurtBox, to ensure the projectile is headed to where it will actually deal damage.
With what script it communicates
AimGuide only communicate directly with AimAssistAreas, to detect them and get the correct aim position from them. Any "Projectile" or "Ranged" State/Weapon can and should use it to get assisted aiming and automate showing the aim preview.