Gameplay / SpringArm
SpringArm Class
Spring arm
Table of contents
Accessors
collisionEnabled(): boolean other |
---|
Enable collision |
collisionInterpSpeed(): number other |
Collision interpolation speed, this value is used to adjust the speed at which the camera returns from a collision state to a non collision state, making the camera collision effect smoother |
length(): number other |
Length of spring arm |
localTransform(): Transform other |
Relative transformation of spring arm |
useControllerRotation(): boolean other |
Use the controller to control rotation |
worldTransform(): Transform other |
World transformation of spring arm |
zoomDistanceRange(): Vector2 other |
Camera zoom range |
zoomEnabled(): boolean other |
Do you want to enable the camera to zoom in and out |
zoomScale(): number other |
Camera zoom distance input ratio |
Accessors
collisionEnabled
• | • | ||||
---|---|---|---|---|---|
Enable collision Precautions After opening, the spring arm will detect the collision object and retract to the collision object nearest to the target Note: To modify the detection trajectory, it is necessary to modify the length of the spring arm (Targeted Arm Length) as well as the targetOffset and slotOffset. Directly modifying the position of the spring arm may result in the offset not triggering collision contraction Usage example: drag the used asset: "26950" into the priority loading column. Create a script called 'Instance_SpringArm', place it in the object bar, open the script, enter the following code to save, run the game, and you will generate 10 pillars in the scene to trigger camera spring rod collision. Press the keyboard '1' to enable/disable camera spring rod collision. You can see the different effects of disabling the camera spring rod collision camera collision pillar. The code is as follows: ts
Returns
| Enable collision Precautions After opening, the spring arm will detect the collision object and retract to the collision object nearest to the target Note: To modify the detection trajectory, it is necessary to modify the length of the spring arm (Targeted Arm Length) as well as the targetOffset and slotOffset. Directly modifying the position of the spring arm may result in the offset not triggering collision contraction Parameters
|
collisionInterpSpeed
• | • | ||||
---|---|---|---|---|---|
Collision interpolation speed, this value is used to adjust the speed at which the camera returns from a collision state to a non collision state, making the camera collision effect smoother Precautions The default value is 2, with an effective range of 0-20. The higher the value, the faster the speed. When it is equal to 0, the camera collision interpolation effect will be turned off; The speed is not fixed, but will change from fast to slow Usage example: drag the used asset: "26950" into the priority loading column. Create a script called 'Instance_SpringArm', place it in the object bar, open the script, enter the following code to save, run the game, and you will generate 10 pillars in the scene to trigger camera spring rod collision. Press the keyboard '1' to enable/disable camera spring rod collision. You can see the different effects of disabling the camera spring rod collision camera collision pillar. The code is as follows: ts
Returns
| Collision interpolation speed, this value is used to adjust the speed at which the camera returns from a collision state to a non collision state, making the camera collision effect smoother Precautions The default value is 2, with an effective range of 0-20. The higher the value, the faster the speed. When it is equal to 0, the camera collision interpolation effect will be turned off; The speed is not fixed, but will change from fast to slow Parameters
|
length
• | • | ||||
---|---|---|---|---|---|
Length of spring arm Precautions Adjust the distance between the camera and the hanging point Usage example: create a script named "Example_SpringArm_Length", place it in the object bar, open the script, enter the following code to save, run the game, press and hold the keyboard "3" to increase the length of the camera spring arm, and press and hold the keyboard "4" to reduce the length of the camera spring arm. In the scene, you will see the spring rod of the camera telescoping. The code is as follows: ts
Returns
| Length of spring arm Precautions Adjust the distance between the camera and the hanging point Parameters
|
localTransform
• | • | ||||
---|---|---|---|---|---|
Relative transformation of spring arm Usage example: create a script named "Example_SpringArm_LocalTransform", place it in the object bar, open the script, enter the following code to save, run the game, press the keyboard "1", switch the offset of the spring arm of the camera (0, 100, 100), and restore it 2 seconds later. You will see the effect of camera offset in the scene and the local transformation of camera spring arm after the change of printing on the console. The code is as follows: ts
Returns
| Relative transformation of spring arm Precautions Relative transformation of spring arm, used to set the relative position, relative rotation and relative scale of spring arm Parameters
|
useControllerRotation
• | • | ||||
---|---|---|---|---|---|
Use the controller to control rotation Precautions After turning on, use the rotation of the controller as the rotation of the camera Example usage: Create a script called "Instance_SpringArm_SseControlRotation", place it in the object bar, open the script, enter the following code to save, run the game, press the keyboard "2", enable/disable the controller to rotate the camera for 5 seconds. You will see in the scene that after disable the controller to operate the camera, you cannot control the camera rotation. The code is as follows: ts
Returns
| Use the controller to control rotation Precautions After turning on, use the rotation of the controller as the rotation of the camera Parameters
|
worldTransform
• | • | ||||
---|---|---|---|---|---|
World transformation of spring arm Precautions World transformation of spring arm, used to set world position, world rotation and world scale of spring arm Usage example: create a script named "Example_SpringArm_WorldTransform", place it in the object bar, open the script, enter the following code to save, run the game, press the keyboard "1", switch the offset of the spring arm of the camera (0, 100, 100), and restore it 2 seconds later. You will see the effect of camera offset in the scene and the world transformation of camera spring arm after the change of printing on the console. The code is as follows: ts
Returns
| World transformation of spring arm Precautions World transformation of spring arm, used to set world position, world rotation and world scale of spring arm Parameters
|
zoomDistanceRange
• | • | ||||
---|---|---|---|---|---|
Camera zoom range Precautions Double finger or mouse scroll zoom camera spring arm length range, default value 60~500 Usage example: create a script named "Example_SpringArm_UseControllerRotation", place it in the object bar, open the script, enter the following code to save, run the game, press the keyboard "2", enable/disable the controller to operate the rotation of the camera for 5 seconds. You will see in the scene the effect that the controller cannot control the rotation of the camera after disable the controller to operate the camera. The code is as follows: ts
Returns
| Camera zoom range Precautions Double finger or mouse scroll zoom camera spring arm length range, default value 60~500 Parameters
|
zoomEnabled
• | • | ||||
---|---|---|---|---|---|
Do you want to enable the camera to zoom in and out Precautions Whether to enable double fingers or mouse wheel to zoom in/out the length of camera spring arm, which is enabled by default, only takes effect when the current camera spring arm length is within the zoom in/out distance of camera Example usage: Create a script called "Instance_SpringArm_SseControlRotation", place it in the object bar, open the script, enter the following code to save, run the game, press the keyboard "2", enable/disable the controller to rotate the camera for 5 seconds. You will see in the scene that after disable the controller to operate the camera, you cannot control the camera rotation. The code is as follows: ts
Returns
| Do you want to enable the camera to zoom in and out Precautions Whether to enable double fingers or mouse wheel to zoom in/out the length of camera spring arm, which is enabled by default, only takes effect when the current camera spring arm length is within the zoom in/out distance of camera Parameters
|
zoomScale
• | • | ||||
---|---|---|---|---|---|
Camera zoom distance input ratio Precautions When controlling the distance between two fingers or scrolling the mouse wheel to change the unit distance, the length of the camera spring arm changes by a default value of 1, with a range of 0-10 Example usage: Create a script called "Instance_SpringArm_SseControlRotation", place it in the object bar, open the script, enter the following code to save, run the game, press the keyboard "2", enable/disable the controller to rotate the camera for 5 seconds. You will see in the scene that after disable the controller to operate the camera, you cannot control the camera rotation. The code is as follows: ts
Returns
| Camera zoom distance input ratio Precautions When controlling the distance between two fingers or scrolling the mouse wheel to change the unit distance, the length of the camera spring arm changes by a default value of 1, with a range of 0-10 Parameters
|