Gameplay / HotWeaponAimComponent
HotWeaponAimComponent Class
The hot weapon aiming component will bring the perspective of the gun wielding character closer in the aiming state
Usage example: create a script named "HotWeaponAimSample1", place it in the object manager, open the script, enter the following code to save, and run the game. The code is as follows:
@Component
export default class HotWeaponAimSample1 extends Script {
protected onStart(): void {
// structure
const hotWeapon = this.gameObject as HotWeapon;
if (SystemUtil.isServer()) {
hotWeapon.aimEnabled = true;
hotWeapon.aimComponent.aimMode = HotWeaponAimMode.ThirdPerson;
hotWeapon.aimComponent.aimingZoom = 16;
hotWeapon.aimComponent.cameraOffsetDistanceInThirdPersonMode = 300;
hotWeapon.aimComponent.onStartAim.add(() => { console.log("aimComponent.onAimStartClient") });
hotWeapon.aimComponent.onEndAim.add(() => { console.log("aimComponent.onAimEndClient") });
} else if (SystemUtil.isClient()) {
hotWeapon.aimComponent.onStartAim.add(() => { console.log("aimComponent.onAimStartClient") });
hotWeapon.aimComponent.onEndAim.add(() => { console.log("aimComponent.onAimEndClient") });
}
}
}
@Component
export default class HotWeaponAimSample1 extends Script {
protected onStart(): void {
// structure
const hotWeapon = this.gameObject as HotWeapon;
if (SystemUtil.isServer()) {
hotWeapon.aimEnabled = true;
hotWeapon.aimComponent.aimMode = HotWeaponAimMode.ThirdPerson;
hotWeapon.aimComponent.aimingZoom = 16;
hotWeapon.aimComponent.cameraOffsetDistanceInThirdPersonMode = 300;
hotWeapon.aimComponent.onStartAim.add(() => { console.log("aimComponent.onAimStartClient") });
hotWeapon.aimComponent.onEndAim.add(() => { console.log("aimComponent.onAimEndClient") });
} else if (SystemUtil.isClient()) {
hotWeapon.aimComponent.onStartAim.add(() => { console.log("aimComponent.onAimStartClient") });
hotWeapon.aimComponent.onEndAim.add(() => { console.log("aimComponent.onAimEndClient") });
}
}
}
Table of contents
Properties
onEndAim: MulticastDelegateInterface <() => void > |
---|
The server-side is starting to target the agents. Example usage: See class HotWeaponAimComponent usage example |
onStartAim: MulticastDelegateInterface <() => void > |
Server side starts aim agent |
Accessors
aimMode(): HotWeaponAimMode other |
---|
Get the first/third person mode when aim. |
aimingZoom(): number other |
Get the magnification of scope when first person aim. |
cameraOffsetDistanceInThirdPersonMode(): number other |
Get the length of the component connecting the camera spring when the third person is aim. |
defaultCameraSpringArmLength(): number other |
Get the default length of the camera spring component in the third person normal state. |
Methods
enableAiming(enabled : boolean ): void other |
---|
Turn on/off aiming |
Properties
onEndAim
• onEndAim: MulticastDelegateInterface
<() => void
>
The server-side is starting to target the agents. Example usage: See class HotWeaponAimComponent usage example
onStartAim
• onStartAim: MulticastDelegateInterface
<() => void
>
Server side starts aim agent
Accessors
aimMode
• | • | ||||
---|---|---|---|---|---|
Get the first/third person mode when aim. Returns
| Set the first/third person mode when aim. Parameters
|
aimingZoom
• | • | ||||
---|---|---|---|---|---|
Get the magnification of scope when first person aim. Precautions The legal range is [1.0, 18.0], and for every 1.0 increase in FOV value corresponding to [0 °, 90 °], the corresponding FOV increases by 5 ° Returns
| Set the magnification of the sight when simulating aiming. For the usage example, see the usage example of the HotWeaponAimComponent class Precautions The legal range is [1.0, 18.0], and for every 1.0 increase in FOV value corresponding to [0 °, 90 °], the corresponding FOV increases by 5 ° Parameters
|
cameraOffsetDistanceInThirdPersonMode
• | • | ||||
---|---|---|---|---|---|
Get the length of the component connecting the camera spring when the third person is aim. Returns
| Set the length of the component connecting the camera spring when the third person is aim. Precautions The length of the camera spring component has a closed range to prevent the camera from getting too close to the Character and causing it to pass through the mold. If it is too far away, it is not necessary Parameters
|
defaultCameraSpringArmLength
• | • | ||||
---|---|---|---|---|---|
Get the default length of the camera spring component in the third person normal state. Returns
| Set the default length of the camera spring component in third person normal. Precautions The length of the camera spring component has a closed range to prevent the camera from getting too close to the Character and causing it to pass through the mold. If it is too far away, it is not necessary Parameters
|
Methods
enableAiming
• enableAiming(enabled
): void
other
Turn on/off aiming
Parameters
enabled boolean | Whether to enable the aiming function default: |
---|
- Switch camera view
- Switch the crosshair UI
- Modify bullet firing accuracy - Ascend to user level, developers can set default accuracy when aiming themselves