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:
@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
• | • | ||||
---|---|---|---|---|---|
Gets the maximum horizontal shake of the camera. Returns
| 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
|
maxHorizontalOffset
• | • | ||||
---|---|---|---|---|---|
Gets the maximum horizontal offset. Returns
| 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
|
maxVerticalJitter
• | • | ||||
---|---|---|---|---|---|
Gets the maximum vertical shake of the camera. Returns
| 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
|
maxVerticalOffset
• | • | ||||
---|---|---|---|---|---|
Gets the maximum vertical offset. Returns
| 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
|
minHorizontalJitter
• | • | ||||
---|---|---|---|---|---|
Gets the minimum horizontal shake of the camera. Returns
| 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
|
minHorizontalOffset
• | • | ||||
---|---|---|---|---|---|
Obtain the minimum horizontal offset value. Returns
| 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
|
minVerticalJitter
• | • | ||||
---|---|---|---|---|---|
Obtain the minimum vertical shake value of the camera. Returns
| 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
|
minVerticalOffset
• | • | ||||
---|---|---|---|---|---|
Obtain the minimum vertical offset value. Returns
| 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
|
Methods
getDeepJitter
• getDeepJitter(): number
other
Obtain the depth jitter value.
Returns
number | Depth jitter value |
---|
getHorizontalJitter
• getHorizontalJitter(): number
other
Obtain the horizontal jitter value.
Returns
number | Horizontal jitter value |
---|
getHorizontalOffset
• getHorizontalOffset(): number
other
Obtain horizontal offset value
Returns
number | Horizontal 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:
@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
number | Vertical shake value |
---|
getVerticalOffset
• getVerticalOffset(): number
other
Obtain the vertical offset value.
Returns
number | Vertical offset value |
---|