【发布时间】:2025-12-17 17:25:07
【问题描述】:
我正在尽最大努力让一个物体掉下来,但到目前为止我什至无法靠近。这是我正在尝试的代码。
BulletAppState bulletAppState = new BulletAppState();
cubemesh = new Box(1f,1f,1f);
Geometry something = new Geometry("cube", cubemesh);
Material bronze = new Material(assetManager,
"Common/MatDefs/Light/Lighting.j3md");
something.setLocalTranslation(0,1,0);
bronze.setTexture("DiffuseMap", assetManager.loadTexture("Textures/bronze.jpg"));
something.setMaterial(bronze);
rootNode.attachChild(something);
RigidBodyControl control = new RigidBodyControl(10f);
Vector3f direction = new Vector3f(0,-9.81f,0);
something.addControl(control);
//all the random lines i've tried
stateManager.attach(bulletAppState);
control.setGravity(direction);
bulletAppState.getPhysicsSpace().setGravity(direction);
rootNode.attachChild(something);
bulletAppState.getPhysicsSpace().add(control);
我们将不胜感激。
【问题讨论】:
-
jME wiki里有很多例子:wiki.jmonkeyengine.org/doku.php/jme3:beginner:hello_physics不管怎样,你把
bulletAppState附加到AppStateManager了吗? -
是的,我在行中添加了,忘记了。
-
你能在屏幕上看到你的对象吗?您的代码无法编译。它也不包括所有必要的东西。请阅读sscce.org 并发布一个完整的示例来重现您的问题。
-
完成,只需使用随机 jpg。 (不想更改变量名)
标签: jmonkeyengine