schteppe / cannon.js

A lightweight 3D physics engine written in JavaScript.
http://schteppe.github.com/cannon.js
MIT License
4.63k stars 700 forks source link

about cannon.js Constraint function of physical engine #452

Open yiuxiu opened 3 years ago

yiuxiu commented 3 years ago

I use a cylinder to simulate a human. When I move a cylinder, how do I write constraint codes to ensure that the cylinder is upright, that is, to prevent people from falling

marcofugaro commented 3 years ago

@yiuxiu you can use the fixedRotation option

http://schteppe.github.io/cannon.js/docs/classes/Body.html

image

yiuxiu commented 3 years ago

@yiuxiu you can use the fixedRotation option

@ yiuxiu 你可以使用 fixedRotation 选项

http://schteppe.github.io/cannon.js/docs/classes/Body.html

image

Thank you. At present, it can also be used. But it's better to let the object rotate around the Y axis and limit the rotation of the X and Z axes

Guo-Zhiqiang commented 3 years ago

If the direction of gravity is along the Y axis,How do I change the direction of the wheels,About RaycastVehicle Class..Here is the address of your code https://github.com/schteppe/cannon.js/blob/master/demos/raycastVehicle.html

marcofugaro commented 3 years ago

@Guo-Zhiqiang check out this example, the gravity is:

world.gravity.set(0, -10, 0)

https://github.com/pmndrs/cannon-es/blob/master/examples/raycast_vehicle.html