[SOLVED] Weird launch effect on sharp edges

Hi there, I am relatively new to JMonkey and just getting started building a simple JumpAndRun. I want to use the blocks framework from GitHub - rvandoosselaer/Blocks: A block (voxel) engine for jMonkeyEngine .
My problem at the moment is that when the character (BetterCharacterControll) jumps onto a block and hits its edge he gets launched into the air, with his velocity increasing from ~4 → over 9. The creator of blocks says its not his framework, so my question is: What in bullet could cause this behavior?

I have had a deeper look into the matter and it seems as if the velocity of the object increases a lot in the collision tick (4 to > 9), so I implemented a custom PhysicsTickListener, but that only solves the problem after each tick, so you can still feel the boost very well. If you want to enable my ‘fix’ remove the comment on line 46 in PhysicsTickHandler.

My code is available as a zip:
https://github.com/rvandoosselaer/Blocks/files/3962411/Coronon-launchEffect.zip

Thank you :slight_smile:

Coronon

1 Like

sorry, i dont open or download any zip files.

But have you maybe tried play with physics options, like setting proper gravity?

bulletAppState.getPhysicsSpace().setGravity(new Vector3f(0, -20f, 0));

or:

bulletAppState.getPhysicsSpace().setAccuracy(0.01f);

?

there are a lot of settings, also for collision shapes too.

Also this looks like you use this framework:

so i assume you already talk with @remy_vd

and im also not sure why your file is under “rvandoosselaer”, do you cooperate in this project or what?

Hi, thanks for the quick reply, yes I already tried setAccuracy, didn’t think setGravity would have any effect, will try.

I uploaded my code to explain him some bugs I found in his code that would crash his framework every time when used on windows (And I don’t have enough rights to upload my code here)

Generally i had issues with BetterCharacterControl myself, its not perfect i know.

Im not sure how “block terrain collision shape” is generated. But for collision shape there are also options that could help.

When i was creating own Voxel library, i had a lot of issues with Collisions, i had freezes and also parts were “throwing fast” or similar issues. But i just had to setup proper collision shape for voxel and i was able to create nice destrucible voxel like here:

The Voxel Engine you choosed(GitHub - rvandoosselaer/Blocks: A block (voxel) engine for jMonkeyEngine ) seems best/newest from available ones.
Its developed by Remy that IMO have high knowledge.

Its nice you already reported issues for him.
If he tell its not “his framework issue”, i can only belive that.

Can i ask you, do his framework create “Collision Shapes” or you create it yourself?(sorry i dont open zip file again)

What i would also check when i would be you, is how other Collision Shapes (other that BetterCharacterControll is using) behave when contact this “hits its edge he gets launched into the air”.
If other collision shapes will also have issues, then i would look issue in collision shape of voxel terrain itself.

Because what i learned based on my own issues, a lot of issues are because of collision shape types.

Hi, thanks for your extensive answer, yeah I will play around with a few other collision shapes then.

The Collision Shape, and node, is generated by his framework as a Mesh, which I then use to create a MeshColissionShape->RigidBodyControll

Mesh mesh = sceneChunk.getCollisionMesh();
mesh.setStatic();
MeshCollisionShape level_shape = new MeshCollisionShape(mesh);
scenePhys = new RigidBodyControl(level_shape, 0.0f);
scene.addControl(scenePhys);

You may want to try a non-BetterCharacterControl test to see if it’s something specific to that class.

Like, create your own rigid body with a capsule shape and see how it behaves against the block edges.

Hi Coronon,

you can also try to visualise the generated collision mesh (to make sure there isn’t something weird in the collision mesh generation), to see what is going in the scene:

Mesh mesh = sceneChunk.getCollisionMesh();
Geometry collision = new Geometry("collision mesh", mesh);
collision.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
collision.getMaterial().setColor("Color", ColorRGBA.Red);
collision.getMaterial().getAdditionalRenderState().setWireframe(true);
collision.setLocalTranslation(chunk.getWorldLocation());
rootNode.attachChild(collision);

or enable bullet debug mode, this will visualise all objects in the physics space:

stateManager.attach(new BulletDebugAppState(bulletAppState.getPhysicsSpace()));

You can use imgur to upload images and link them here.

My next step would be to try to swap out the BetterCharacterControl as Paul mentioned. Creating a CapsuleCollisionShape and push it with some forces against the blocks.

2 Likes

I unzipped your code but was unable to execute it because the “NUTJumpNRun” library was missing.

Yeah, you just need to add a new library with all the jar files in the ‘libs’ folder :slight_smile:

Please try what @remy_vd said.

Anyway MeshCollisionShape was the one most problematic for me.

I am using CompoundCollisionShape that have GImpactCollisionShape. Because my parts are moving.

As i know if mesh is static, MeshCollisionShape should not be problematic, so idk here.

The best would be video with visualised physics like Remy suggested to see what happends.

An image of the debug view: Imgur: The magic of the Internet

I will try out some other shape then, my only problem is, that I am relatively new to Java (Python is my long main language) and that I just started using JME. Should I extend BetterCharacterControl and change the getShape() or write a completely new one?

yes, but what exactly need is Video/screenshot of some “moveable” Collision shapes that contact terrain edges.

I will try out some other shape then, my only problem is, that I am relatively new to Java (Python is my long main language) and that I just started using JME. Should I extend BetterCharacterControl and change the getShape() or write a completely new one?

The new one i belive.

Like people mentioned:

My next step would be to try to swap out the BetterCharacterControl as Paul mentioned. Creating a CapsuleCollisionShape and push it with some forces against the blocks.

You may want to try a non-BetterCharacterControl test to see if it’s something specific to that class.

Like, create your own rigid body with a capsule shape and see how it behaves against the block edges.

What i would also check when i would be you, is how other Collision Shapes (other that BetterCharacterControll is using) behave when contact this “hits its edge he gets launched into the air”.
If other collision shapes will also have issues, then i would look issue in collision shape of voxel terrain itself.

so 3 people suggested the same thing trully.

It might be helpful to know which libraries and their version numbers.

Its Blocks1.1.1 and all its requirements for logging

1 Like

Does the same effect occur with Blocks 1.2.1?

Is your trouble resolved?

Yes, we bodged the physics a little bit. Thanks for the help :slight_smile:

2 Likes