Skip to content
HotWeaponRecoilForceComponent

Gameplay / HotWeaponRecoilForceComponent

HotWeaponRecoilForceComponent Class ​

Thermal weapon recoil component, used to control the shaking (automatically restored) and offset (not automatically restored) of the character's perspective during launch

Usage example: create a script named "HotWeaponRecoverForceSample1", place it in the object manager, open the script, enter the following code to save, and run the game. The code is as follows:

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

        if (SystemUtil.isServer()) {
            hotWeapon.recoilForceEnabled = true;
            hotWeapon.recoilForceComponent.minHorizontalOffset = 1
            hotWeapon.recoilForceComponent.maxHorizontalOffset = 1
            hotWeapon.recoilForceComponent.minVerticalOffset = 1
            hotWeapon.recoilForceComponent.maxVerticalOffset = 1
            hotWeapon.recoilForceComponent.minHorizontalJitter = 1;
            hotWeapon.recoilForceComponent.maxHorizontalJitter = 1;
            hotWeapon.recoilForceComponent.minVerticalJitter = 1;
            hotWeapon.recoilForceComponent.maxVerticalJitter = 1;
        }
        hotWeapon.recoilForceComponent.onStartRecoil.add(() => { console.log("recoilForceComponent.onStartRecoilForce") });
    }
}
@Component
export default class HotWeaponRecoilForceSample1 extends Script {
    protected onStart(): void {
        // structure
        const hotWeapon = this.gameObject as HotWeapon;

        if (SystemUtil.isServer()) {
            hotWeapon.recoilForceEnabled = true;
            hotWeapon.recoilForceComponent.minHorizontalOffset = 1
            hotWeapon.recoilForceComponent.maxHorizontalOffset = 1
            hotWeapon.recoilForceComponent.minVerticalOffset = 1
            hotWeapon.recoilForceComponent.maxVerticalOffset = 1
            hotWeapon.recoilForceComponent.minHorizontalJitter = 1;
            hotWeapon.recoilForceComponent.maxHorizontalJitter = 1;
            hotWeapon.recoilForceComponent.minVerticalJitter = 1;
            hotWeapon.recoilForceComponent.maxVerticalJitter = 1;
        }
        hotWeapon.recoilForceComponent.onStartRecoil.add(() => { console.log("recoilForceComponent.onStartRecoilForce") });
    }
}

Table of contents ​

Properties ​

onStartRecoil: MulticastDelegateInterface<() => void>
Recoil starts broadcasting.

Accessors ​

maxHorizontalJitter(): number other
Gets the maximum horizontal shake of the camera.
maxHorizontalOffset(): number other
Gets the maximum horizontal offset.
maxVerticalJitter(): number other
Gets the maximum vertical shake of the camera.
maxVerticalOffset(): number other
Gets the maximum vertical offset.
minHorizontalJitter(): number other
Gets the minimum horizontal shake of the camera.
minHorizontalOffset(): number other
Obtain the minimum horizontal offset value.
minVerticalJitter(): number other
Obtain the minimum vertical shake value of the camera.
minVerticalOffset(): number other
Obtain the minimum vertical offset value.

Methods ​

getDeepJitter(): number other
Obtain the depth jitter value.
getHorizontalJitter(): number other
Obtain the horizontal jitter value.
getHorizontalOffset(): number other
Obtain horizontal offset value
getVerticalJitter(): number other
Obtain the vertical jitter value.
getVerticalOffset(): number other
Obtain the vertical offset value.

Properties ​

onStartRecoil ​

• onStartRecoil: MulticastDelegateInterface<() => void>

Recoil starts broadcasting.

Accessors ​

maxHorizontalJitter ​

• get maxHorizontalJitter(): number other

• set maxHorizontalJitter(value): void other

Gets the maximum horizontal shake of the camera.

Returns ​

numberMaximum horizontal camera shake

Sets the maximum horizontal shake of the camera.

Precautions

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

Parameters ​

value numberMaximum camera horizontal shake
default: 0
range: [-5, 5] type: floating point

maxHorizontalOffset ​

• get maxHorizontalOffset(): number other

• set maxHorizontalOffset(value): void other

Gets the maximum horizontal offset.

Returns ​

numberMaximum horizontal offset

Sets the maximum horizontal offset.

Precautions

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

Parameters ​

value numberMaximum horizontal offset
default: 0
range: [-5,5] type: floating-point number

maxVerticalJitter ​

• get maxVerticalJitter(): number other

• set maxVerticalJitter(value): void other

Gets the maximum vertical shake of the camera.

Returns ​

numberMaximum vertical camera shake

Set the maximum vertical shake value for the camera.

Precautions

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

Parameters ​

value numberMaximum vertical shake of new camera
default: 0
range: [-5, 5] type: floating point

maxVerticalOffset ​

• get maxVerticalOffset(): number other

• set maxVerticalOffset(value): void other

Gets the maximum vertical offset.

Returns ​

numberMaximum vertical offset

Sets the maximum vertical offset.

Precautions

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

Parameters ​

value numberMaximum vertical offset
default: 0
range: [-5,5] type: floating-point number

minHorizontalJitter ​

• get minHorizontalJitter(): number other

• set minHorizontalJitter(value): void other

Gets the minimum horizontal shake of the camera.

Returns ​

numberCamera horizontal shake minimum

Set the minimum horizontal shake value for the camera.

Precautions

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

Parameters ​

value numberMinimum horizontal shake of new camera
default: 0
range: [-5, 5] type: floating point

minHorizontalOffset ​

• get minHorizontalOffset(): number other

• set minHorizontalOffset(value): void other

Obtain the minimum horizontal offset value.

Returns ​

numberMinimum horizontal offset

Set the minimum horizontal offset value.

Precautions

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

Parameters ​

value numberMinimum value of horizontal offset
default: 0
range: [-5, 5] type: floating point number type: floating point number

minVerticalJitter ​

• get minVerticalJitter(): number other

• set minVerticalJitter(value): void other

Obtain the minimum vertical shake value of the camera.

Returns ​

numberCamera vertical shake minimum

Sets the camera vertical shake minimum value.

Precautions

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

Parameters ​

value numberMinimum vertical shake of new camera
default: 0
range: [-5, 5] type: floating point

minVerticalOffset ​

• get minVerticalOffset(): number other

• set minVerticalOffset(value): void other

Obtain the minimum vertical offset value.

Returns ​

numberVertical offset minimum

Sets the minimum value of vertical offset.

Precautions

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

Parameters ​

value numberMinimum value of vertical offset
default: 0
range: [-5, 5] type: floating point number

Methods ​

getDeepJitter ​

• getDeepJitter(): number other

Obtain the depth jitter value.

Returns ​

numberDepth jitter value

getHorizontalJitter ​

• getHorizontalJitter(): number other

Obtain the horizontal jitter value.

Returns ​

numberHorizontal jitter value

getHorizontalOffset ​

• getHorizontalOffset(): number other

Obtain horizontal offset value

Returns ​

numberHorizontal offset value

Usage example: create a script named "HotWeaponRecoilForceSample2", place it in the object manager, open the script, enter the following code to save, run the game, and you will see the effect of a thermal weapon recoil component in the scene to obtain the current key state. The code is as follows:

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

        const horizontalOffset = hotWeapon.recoilForceComponent.getHorizontalOffset();
        const verticalOffset = hotWeapon.recoilForceComponent.getVerticalOffset();
        const horizontalJitter = hotWeapon.recoilForceComponent.getHorizontalJitter();
        const verticalJitter = hotWeapon.recoilForceComponent.getVerticalJitter();
        const deepJitter = hotWeapon.recoilForceComponent.getDeepJitter();
    }
}
@Component
export default class HotWeaponRecoilForceSample2 extends mw.Script {
    protected onStart(): void {
        // structure
        const hotWeapon = this.gameObject as mw.HotWeapon;

        const horizontalOffset = hotWeapon.recoilForceComponent.getHorizontalOffset();
        const verticalOffset = hotWeapon.recoilForceComponent.getVerticalOffset();
        const horizontalJitter = hotWeapon.recoilForceComponent.getHorizontalJitter();
        const verticalJitter = hotWeapon.recoilForceComponent.getVerticalJitter();
        const deepJitter = hotWeapon.recoilForceComponent.getDeepJitter();
    }
}

getVerticalJitter ​

• getVerticalJitter(): number other

Obtain the vertical jitter value.

Returns ​

numberVertical shake value

getVerticalOffset ​

• getVerticalOffset(): number other

Obtain the vertical offset value.

Returns ​

numberVertical offset value