I encountered some issues while writing this demo,
When I load a mesh, I want to add Constraints between two objects. My idea is to constantly set parents to obtain positions and then connect them together,there is an error where the position of the body shape and the position of the mesh are not at the same point
I don’t think my approach is correct, I don’t know how to operate the correct approach
const meshes = wheel.getChildMeshes()
meshes[0].position = $.Vector3.Zero()
meshes[1].position = $.Vector3.Zero()
// set parent inorder to adjust wheel position
wheel.parent = carBody
// This is to obtain the positions of the four wheel axles, And then I can hope to install the wheels on it
const name = meshes[0].name.slice(0, meshes[0].name.length - 1) + '2'
const pivot = this.scene.getMeshByName(name)
wheel.position = pivot.position.clone()
How should I set the parameters in the constraint
// set Constraints
const joint = new $.BallAndSocketConstraint(
wheel.position,
wheel.position,
wheel.position,
wheel.position,
scene
)
Hi, master
axisA: new BABYLON.Vector3(1, 0, 0),
axisB: new BABYLON.Vector3(1, 0, 0),
perpAxisA: new BABYLON.Vector3(0,1,0),
perpAxisB: new BABYLON.Vector3(0,1,0)
In Physics6DoFConstraint, do you only need to set two of these four parameters?
If 4 are set at the same time, axisA and perpAxisA will occasionally twitch.
Literally understood from the document, the parameter axisA is to determine and set LINEAR_X/ANGULAR_X. Therefore, perpAxisA has also been implemented. If you set perpAxisA again and do not keep it unified with axisA, it will twitch.
An axis in the space of the first body which determines how
distances/angles are measured for LINEAR_X/ANGULAR_X limits.
Is there any problem with my understanding? Can you please give me some advice?
If the axisA is provided as (1,0,0), the getNormalToRef function results in (0,-1,0), which might not be what you expect: Babylon.js Playground (babylonjs.com). If you want to control the axis precisely, it’s preferrable to provide all of them.
Hi! There’s currently a bug with the physics system, where you need to apply a small impulse to the wheels to make the setAxisMotorTarget work. With that, the car can start and stop I updated the demo with that, and turning the wheels too (thanks @eoin for answering my questions!) Physics Car | Babylon.js Playground (babylonjs.com)