Closed CrazyWords1 closed 4 months ago
@CrazyWords1 In general, applyCentralImpulse()
ought to have some effect on the sphere's motion. I wonder about the sphere's mass and radius. Can you provide a simple test case?
I can hardly provide a normal test case, I'm using a special environment for rapid development, not java. I think that may be the problem. But everything else works. Even the cars. I will try to provide the code in the necessary way, exactly the methods I use. I apologize in advance for my English, it's not my main language.
P.S(The test environment is compatible with java via reflection, i.e. all methods are called using java.lang.reflect)
func loadLibrary():
downloadDirectory = new File("phys/")
NativeLibraryLoader.loadLibbulletjme(true, downloadDirectory, "Release", "SpMt")
func createSphere(radius: number, loc: location, mass: number):
//here was the code to create a visual model
// _ prefix for local vars
_sphere = new SphereCollisionShape(_radius/2)
// :: aka array
spheres::%_uuid% = new PhysicsRigidBody(_sphere, _mass)
physicsSpace.addCollisionObject(spheres::%_uuid%)
spheres::%_uuid%.PhysicsLocation(locationToVector3(_loc))
return spheres::%_uuid%
physicsSpace = new PhysicsSpace(PhysicsSpace.BroadphaseType.DBVT)
testSphere = createSphere(2, location(-348, 80, 381), 2)
testSphere.applyCentralImpulse(new Vector3f(-25, 0, 0))
timeStep = 0.01
while true:
physicsSpace.update(timeStep, 0)
updateVisual()
//here func for sleep 50ms
P.S (Also wanted to add that if I use another method for testSphere, like applyCentruuulForce, I get the error, "No such Method, Perhaps you wanted to use applyCentralForce ? ")
If you tell me that your code works differently, I'll go look for a bug in my environment, but it's strange that all other methods work. I also wanted to say a huge thank you for developing this library. For my game at the moment it's a major boon, the holy grail
I verified that applyCentralForce()
works as expected using tutorial code, specifically HelloRigidBody.
I don't see any major problems with your code, though it seems strange to update every 50 ms while advancing the physics by only 10 ms.
I wonder what would happen if you increased the magnitude of the impulse by 10x. Another debugging approach would be to print the velocity of the sphere after each physics update.
While I was testing, decided to upgrade to the new version, everything broke :(
[17:34:01 INFO]: [com.jme3.system.NativeLibraryLoader] Loading native library from /home/crazywords/phys/Linux64DebugSp_libbulletjme.so
> Debug_Libbulletjme version 21.1.0 initializing
[17:34:01 WARN]: [com.jme3.bullet.util.NativeLibrary] Expected a v20.2.0 native library but loaded v21.1.0!
[17:34:01 INFO]: constructor PhysicsSpace#<init> called with (DBVT (BroadphaseType)) threw a NullPointerException: The construction info does not exist.
UPD (I went back to version 20.2.0, everything worked)
Gosh, I don't know why, but after I went back to the old version and rebooted the server, everything worked, including applyCentralImpulse
Between v20.2.0 and v21.0.0 there were incompatible changes to the API the JVM library uses to "talk to" the native library. If you upgrade one, you must upgrade the both. The warning indicates you somehow failed to do so.
Thank you so much for the replies, at the moment with your advice, everything worked!
I'm glad!
I created a sphere, when I run the test scene, the sphere drops and interacts with the colliders, everything is great in that, but when I try to apply (force) to the sphere, nothing happens. What i do wrong? P.S ( applyCentralImpulse(new Vector3f(-25f, 0f, 0f)) )