Cursor Aiming
If you wish to control weapons functions such as aiming and target selection with the mouse cursor, add an Aim Controller component to the root transform of your vehicle.
The Aim Controller component gives you several functions to improve the gameplay experience.
Cursor Aiming
With cursor aiming, the weapons will all point toward the cursor as it moves around the screen.
To enable this, check the Cursor Aiming checkbox in the inspector of the Aim Controller component.
You must have a HUD Cursor component set up on your vehicle. Drag it into the HUD Cursor field in the inspector of the Aim Controller component.
Raycast Aiming
In third person view, for example, the camera may be at a different height than the vehicle, making aiming the vehicle's weapons difficult. With raycast aiming, this is no longer a problem. A raycast will be fired through the cursor, and the weapons will aim at whatever it hits.
To enable this, check the Raycast Aim checkbox in the inspector of the Aim Controller component. It is highly recommended to check the Use Camera As Raycast Origin checkbox as well, as this is necessary for accurate third person aiming.
Aim Assist
With aim assist, the weapons will snap toward a target when the cursor is close to it, which means the player doesn't have to be absolutely precise, especially when aiming at a far away target.
To enable this, check the Aim Assist checkbox in the inspector of the Aim Controller component, and set the Aim Assist Angle to your liking.
For the aim assist to work properly when leading targets, you must have a Weapons component on the root transform of your vehicle. Drag it into the Weapons field in the inspector of the Aim Controller component.
Responsive Reticle
You can make the reticle change color when it is within the aim assist angle defined on the AIm Controller component.
Add a UI Color Manager component anywhere on the vehicle
Add all the visual elements of the reticle to it
Drag it into the HUD Cursor Color Manager field in the inspector of the Aim Controller component.
Customize the Aim Assist color in the inspector of the Aim Controller component
Now, when the cursor is near a target it will turn red (or whatever color you have defined).
Cursor Target Selection
If you have a target selector set up on your vehicle, you can have it select whatever target is under the cursor.
To enable this, check the Aim Target Selection Enabled checkbox in the inspector of the Aim Controller component. You will need to have a Tracker and a Target Selector already set up on your vehicle, and drag them into the appropriate fields in the inspector.
Turret Aiming
If you have turrets on your vehicle (such as on a capital ship), you will want the turrets to aim toward the position calculated by the Aim Controller.
To set this up:
Create a new game object under the vehicle
Drag it into the Aim Position Marker field in the inspector of the Aim Controller component.
Drag it into the Turrets Target Transform field in the inspector of the Weapons component.
Now, this object will be positioned where the aim controller is aiming, and the turrets will track it.
Last updated