lo-th / Oimo.js

Lightweight 3d physics engine for javascript
http://lo-th.github.io/Oimo.js
MIT License
3.05k stars 301 forks source link

Is it possible to move a Rigidbody without using force? #92

Open mathiasdeoliveira opened 4 years ago

mathiasdeoliveira commented 4 years ago

Hello,

I'm a beginner with this lib.

Currently I can move my rigidbody with a force, the problem is that the object in question is a player so when the user releases the key, the player keeps moving forward.

I tried to move my mesh, and modify the position of my rigidbody according to it, I manage to get the contacts between my player and my obstacles except that with this method my player passes through my obstacles.

Is there anything in the lib that can solve my problem?

icedcoke commented 4 years ago

你好,你可以用linearVelocity去设置物体的速度,这样可以保留物体的碰撞效果,同时停止的时候设置速度为零就可以了。在遇到问题可以查看下源代码,里面可以有想要的答案。 例如这样设置: oimoBody.linearVelocity.set(0, 100, 0);