Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shapeの座標をずらしたらおかしい #27

Closed
takeru opened this issue Apr 11, 2020 · 3 comments
Closed

Shapeの座標をずらしたらおかしい #27

takeru opened this issue Apr 11, 2020 · 3 comments

Comments

@takeru
Copy link

takeru commented Apr 11, 2020

https://jsfiddle.net/ssktkr/qmsctw51/

If you move the coordinates of the shape from the center of RigidBody and add it, it will move like a pendulum.
Is it being used incorrectly?

Shapeの座標をRigidBodyの中心からずらしてaddすると振り子のような動きになってしまいます。
使い方が間違っていますか?

@saharan
Copy link
Owner

saharan commented Apr 12, 2020

As the position of a RigidBody represents the center of gravity of the rigid body, and the position of a Shape (ShapeConfig.position in the code) represents the (local) relative position to the rigid body's center of gravity, it is an expected behavior that the rigid body moves like a pendulum.
If you want to place the shape at the center of gravity of the rigid body, please adjust the rigid body's position instead of the shape's position.

RigidBodyの中心は剛体の重心で、Shapeの座標はRigidBodyの重心からのずれを表すので、振り子のような動きをするのは想定された動作です。Shapeを重心に置きたい場合は、Shapeの座標の代わりにRigidBodyの座標を調節してください。

@saharan
Copy link
Owner

saharan commented Apr 12, 2020

Although it's an expected behavior, it's favorable to automatically update the center of gravity. This will be handled in #28.

重心がずれるのは想定された動作ですが、自動で重心を計算できる方が好ましいので、将来的に重心とRigidBodyの原点を分けて扱い、重心の座標を自動計算できるようにしようと思います(#28)。

@takeru
Copy link
Author

takeru commented Apr 13, 2020

https://twitter.com/shr_em/status/1249245606972772352
https://jsfiddle.net/ssktkr/w560mbfx/
今のバージョン(1.2.0)のままでなんとかするサンプルです。たぶんなんとかなってるとおもいます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants