Skip to content
HotWeaponFireComponent

Gameplay / HotWeaponFireComponent

HotWeaponFireComponent Class

Thermal weapon firing component, responsible for maintaining the main parameters and core logic of thermal weapon firing

Example usage: Create a script named "HotWeaponFireSample1", place it in the child node of the object manager's hot weapon, open the script, enter the following code to save, run the game, the code is as follows:

ts
@Component
 export default class HotWeaponFireSample1 extends Script {
     protected onStart(): void {
         // structure
         const hotWeapon = this.gameObject as HotWeapon;

         if (SystemUtil.isServer()) {
             hotWeapon.fireComponent.isFireOnScreenCenter = false;
             hotWeapon.fireComponent.clipSize = 50;
             hotWeapon.fireComponent.fireInterval = 0;
             hotWeapon.fireComponent.multipleShot = 3;
             hotWeapon.fireComponent.isFireOnScreenCenter = false;
             hotWeapon.fireComponent.offsetOfFireOnScreenCenter = new Vector(100, 30, 0);
             // Set parameters
             hotWeapon.fireComponent.animationAssetId = "80484";
             hotWeapon.fireComponent.onStartFire.add(() => { console.log("fireComponent.onStartFireClient") });
             hotWeapon.fireComponent.onEndFire.add(() => { console.log("fireComponent.onEndFireClient") });
             hotWeapon.fireComponent.onEndContinuousFire.add(() => { console.log("fireComponent.onEndFireClient") });
         }
     }
 }
@Component
 export default class HotWeaponFireSample1 extends Script {
     protected onStart(): void {
         // structure
         const hotWeapon = this.gameObject as HotWeapon;

         if (SystemUtil.isServer()) {
             hotWeapon.fireComponent.isFireOnScreenCenter = false;
             hotWeapon.fireComponent.clipSize = 50;
             hotWeapon.fireComponent.fireInterval = 0;
             hotWeapon.fireComponent.multipleShot = 3;
             hotWeapon.fireComponent.isFireOnScreenCenter = false;
             hotWeapon.fireComponent.offsetOfFireOnScreenCenter = new Vector(100, 30, 0);
             // Set parameters
             hotWeapon.fireComponent.animationAssetId = "80484";
             hotWeapon.fireComponent.onStartFire.add(() => { console.log("fireComponent.onStartFireClient") });
             hotWeapon.fireComponent.onEndFire.add(() => { console.log("fireComponent.onEndFireClient") });
             hotWeapon.fireComponent.onEndContinuousFire.add(() => { console.log("fireComponent.onEndFireClient") });
         }
     }
 }

Table of contents

Properties

onEndContinuousFire: MulticastDelegateInterface<() => void>
The server executes the binding function when it finishes a burst fire shoot cycle. Example usage of class HotWeaponFireComponent
onEndFire: MulticastDelegateInterface<() => void>
Execute binding function when the server stops firing. Example usage of class HotWeaponFireComponent
onStartFire: MulticastDelegateInterface<() => void>
Execute binding function when the server starts firing. For the usage example, see the usage example of the class HotWeaponFireComponent

Accessors

animationAssetId(): string other
Binding animation UID. Example usage of class HotWeaponFireComponent
clipSize(): number other
Get the current magazine capacity. For the usage example, see the usage example of the class HotWeaponFireComponent
currentBullet(): number other
Get the number of bullets in the current magazine. For the usage example, see the usage example of the class HotWeaponFireComponent
fireInterval(): number other
Obtain the firing gap. For the usage example, see the usage example of the class HotWeaponFireComponent
fireMode(): HotWeaponFireMode other
Get the current firing mode
isFireOnScreenCenter(): boolean other
Gets whether to fire in the center of the screen. Example usage of class HotWeaponFireComponent
multipleShot(): number other
Obtain the number of bullets fired at once. For the usage example, see the usage example of the class HotWeaponFireComponent
offsetOfFireOnScreenCenter(): Vector other
Get the offset when the screen center fires. Example usage of class HotWeaponFireComponent

Methods

isFiring(): boolean other
Obtain the value of bFiring in the current state, which is generally used to process automatic reload change in fully automatic firing mode

Properties

onEndContinuousFire

onEndContinuousFire: MulticastDelegateInterface<() => void>

The server executes the binding function when it finishes a burst fire shoot cycle. Example usage of class HotWeaponFireComponent


onEndFire

onEndFire: MulticastDelegateInterface<() => void>

Execute binding function when the server stops firing. Example usage of class HotWeaponFireComponent


onStartFire

onStartFire: MulticastDelegateInterface<() => void>

Execute binding function when the server starts firing. For the usage example, see the usage example of the class HotWeaponFireComponent

Accessors

animationAssetId

get animationAssetId(): string other

set animationAssetId(GUID): void other

Binding animation UID. Example usage of class HotWeaponFireComponent

Returns

stringBound animation GUID

Set the animation GUID. Example usage of class HotWeaponFireComponent

Parameters

GUID stringMontage animation GUID range to be set: depends on the length of asset ID

clipSize

get clipSize(): number other

set clipSize(value): void other

Get the current magazine capacity. For the usage example, see the usage example of the class HotWeaponFireComponent

Returns

numberCurrent magazine capacity

Set the current magazine capacity. For the usage example, see the usage example of the class HotWeaponFireComponent

Precautions

Only the server can be called before equipping the hot weapon, and both ends can be called after equipping

Parameters

value numberCurrent magazine capacity
default: 30
range: [1,1000] type: integer

currentBullet

get currentBullet(): number other

set currentBullet(value): void other

Get the number of bullets in the current magazine. For the usage example, see the usage example of the class HotWeaponFireComponent

Returns

numberThe current number of bullets in the magazine

Set the number of bullets in the current magazine. Example usage of class HotWeaponFireComponent

Parameters

value numberNumber of bullets in new magazine
default: 0
range: [0, clipSize] type: integer

fireInterval

get fireInterval(): number other

set fireInterval(interval): void other

Obtain the firing gap. For the usage example, see the usage example of the class HotWeaponFireComponent

Returns

numberOpening gap

Set the firing gap. Example usage of class HotWeaponFireComponent

Precautions

Only the server can be called before equipping the hot weapon, and both ends can be called after equipping

Parameters

interval numberOpening gap
default: 0.1
range: [0.01, 10] type: floating point number

fireMode

get fireMode(): HotWeaponFireMode other

set fireMode(newFireMode): void other

Get the current firing mode

Returns

HotWeaponFireModeCurrent firing mode

Switch and set the current firing mode

Precautions

Before equipment, it can only be call on the server, and after equipment, it can be call on the client

Parameters

newFireMode HotWeaponFireModeNew Hot Weapon firing mode
default: default is single-shot HotWeaponFireMode SingleFire

isFireOnScreenCenter

get isFireOnScreenCenter(): boolean other

set isFireOnScreenCenter(value): void other

Gets whether to fire in the center of the screen. Example usage of class HotWeaponFireComponent

Returns

booleanWhether to fire in the center of screen

Set whether to fire in the center of the screen. For the usage example, see the usage example of the class HotWeaponFireComponent

Precautions

Only the server can be called before equipping the hot weapon, and both ends can be called after equipping

Parameters

value booleanWhether to fire in the center of screen

multipleShot

get multipleShot(): number other

set multipleShot(count): void other

Obtain the number of bullets fired at once. For the usage example, see the usage example of the class HotWeaponFireComponent

Returns

numberThe number of bullets fired at once

Set the number of bullets fired at once. For the usage example, see the usage example of the class HotWeaponFireComponent

Precautions

Only the server can be called before equipping the hot weapon, and both ends can be called after equipping

Parameters

count numberNumber of bullets fired at once
default: 1
range: [1,100] type: integer

offsetOfFireOnScreenCenter

get offsetOfFireOnScreenCenter(): Vector other

set offsetOfFireOnScreenCenter(offset): void other

Get the offset when the screen center fires. Example usage of class HotWeaponFireComponent

Returns

VectorOffset when the screen center fires

Set the offset when firing from the center of the screen. Example usage of class HotWeaponFireComponent

Precautions

Only the server can be called before equipping the hot weapon, and both ends can be called after equipping

Parameters

offset VectorOffset when the screen center fires

Methods

isFiring

isFiring(): boolean other

Obtain the value of bFiring in the current state, which is generally used to process automatic reload change in fully automatic firing mode

Returns

booleanThe current number of bullets in the magazine