schteppe / cannon.js

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

How can I apply a force to an object to make it move in the specified direction? API is not very clear #453

Open yiuxiu opened 3 years ago

yiuxiu commented 3 years ago

How can I apply a force to an object to make it move in the specified direction? API is not very clear

marcofugaro commented 3 years ago

@yiuxiu check out the Impulses example.

You apply impulses like this

https://github.com/pmndrs/cannon-es/blob/9d65831bf8834e2a4f721dad515ebd8ed639ec29/examples/impulses.html#L40-L41

Guo-Zhiqiang commented 3 years ago

How can I apply a force to an object to make it move in the specified direction? API is not very clear

CANNON.Body.velocity Class