Physics Thruster
TIP
It takes about 10 minutes to read this article.
This article outlines the definitions and instructions of Physics Thrusters in the editor.
What is a Physics Thruster
Physics Thruster is a functional object with physical properties that can add a continuous force to an object with physical simulation enabled, pushing it to perform physical motion.
How to create a Physics Thruster
- Step.1 Add a Physics Thruster to the model Search for [Physics Thruster] in the local asset library, find the functional object, drag the Physics Thruster to the child of the object that needs to be pushed, and complete the binding. The object being pushed needs to turn on physical simulation, and the physical simulation of the model refers to the physical object.
- Step.2 Set the direction of the thruster and the force of the thruster
The direction and magnitude of the force are set by the properties of the Physics Thruster. Note: The direction of the blue arrow in the viewport is the direction of the force.
How to enable the Physics Thruster feature
- Enable via the properties panel
Select [Open] in the Properties panel, and the Physics Thrusters will immediately apply thrust and start physical simulation calculations when you run the game.
- Control via script
@Component
export default class NewScript extends Script {
/** The function is called when the script is instantiated, before the first frame of the game */
protected onStart(): void {
let ThrusterMain = this.gameObject as mw.PhysicsThruster; //Specify the Physics Thruster
//Set the thrust value. The thrust value needs to refer to the object being pushed and the current world gravity. For example, if the current world gravity is -1600 and the mass of the object being pushed is 1000, the thrust needs to be greater than (1600*1000) to push it off the ground.
ThrusterMain.strength = 165000;
//Thrusters can be enabled at a specified time through the API
ThrusterMain.enable = true;
}
}
@Component
export default class NewScript extends Script {
/** The function is called when the script is instantiated, before the first frame of the game */
protected onStart(): void {
let ThrusterMain = this.gameObject as mw.PhysicsThruster; //Specify the Physics Thruster
//Set the thrust value. The thrust value needs to refer to the object being pushed and the current world gravity. For example, if the current world gravity is -1600 and the mass of the object being pushed is 1000, the thrust needs to be greater than (1600*1000) to push it off the ground.
ThrusterMain.strength = 165000;
//Thrusters can be enabled at a specified time through the API
ThrusterMain.enable = true;
}
}
Precautions and suggestions for using thrusters
The thruster releases propulsion outward with the functional object itself as the center. During physical simulation, the final motion result will be simulated according to the mass of the object being pushed and the size of the propulsion force. The greater the mass of the object being pushed, the greater the thrust required.