Comments (6)
Thanks for your help.
from cannon-es.
Hey @anemol
Thanks for using cannon-es, yes we are working on updating the examples and documentation so it's more accessible
In your example, your world simulation is correctly running at 30fps.
However, that is not the issue. Cannon.js has implemented a "discrete" collision detection, which means that fast moving bodies can go through wall. Read more about it here
Just using the default parameters, the situation is greatly improved in your example.
var world = new CANNON.World();
world.gravity.set(0,-40,0);
var fixedTimeStep = 1.0 / 30.0; // seconds
var maxSubSteps = 3;
I would also limit the velocity of your body in the -Y
direction each frame, with something like:
body.velocity.y = Math.max(body.velocity.y, -1)
So that it doesn't fall that fast.
from cannon-es.
I see you have closed the issue.
Thank you for your reply. Unfortunately, the changes don't solve the problem and the speed limit makes the jump unrealistic.
The problem is mainly with the custom form (ramp); for the boxes, it is ok. So, i have doubt about the ramp.
Can you confirm that its definition is correct? Thanks.
var w = 0.5 * o.sx; // half width
var h = 0.5 * o.sy; // half height
var d = 0.5 * o.sz; // half depth
var verts=[
new CANNON.Vec3(-w, -h, +d), //0
new CANNON.Vec3(-w, +h, +d), //1
new CANNON.Vec3(-w, +h, -d), //2
new CANNON.Vec3(-w, -h, -d), //3
new CANNON.Vec3(+w, -h, -d), //4
new CANNON.Vec3(+w, -h, +d), //5
];
var faces=[
[0,1,2,3],
[0,3,4,5],
[0,5,1],
[2,4,3],
[1,5,4,2],
];
var rampShape= new CANNON.ConvexPolyhedron({vertices: verts,faces: faces});
from cannon-es.
Yeah sure it looks correct! Here is a ConvexPolyhedron in the examples.
Could you maybe make a screencast of the problems you're having?
from cannon-es.
The screenshot of the first message shows the problem: the wheel of the charactere penetrates into the ramp. (sometime, all the charactere).
You can reproduce easily with my little online demo: https://littleworldofsatoshi.com/testRamp
Go on to the ramp and jump. After some jumps, the wheel will penetrate or pass through the ramp. :)
I changed the world settings following your advice by only:
var world = new CANNON.World();
from cannon-es.
In your specific case, you just have to make the ball bigger. This helps not falling through the ground. You can visualize the babylon mesh smaller if you want, and achieve the same result.
https://i.imgur.com/NkjoYNh.mp4
It's not a specific science, you just have to play around with it man.
I'd suggest you using stack overflow next time, there are more people that can help you there.
from cannon-es.
Related Issues (20)
- Please, add Debug Drawer HOT 18
- Fixing the local axes orientation of an exported gltf model to get the correct quaternion coordinates
- Calling getVelocityAtWorldPoint yields Uncaught TypeError: worldPoint.vsub is not a function
- how to find a constraint ?
- console.log on ConvexPolyhedron.ts
- Orientation of a body HOT 1
- Chaining Hinges behaviour
- [ Question ] Spheres going through body with mass equal zero
- penetrate explosion
- The movement of a spinning ball in cannon js has an unexpected deviation that depends on the direction of the movement itself
- can anyone help me about using webpack to use it in one js file ?
- Documentation question: After getting the red box wireframe working, and want to get gray boxes bouncing...
- ConvexPolyhedron: Tetrahedron working vs. not working HOT 3
- DisableMotor() method does not work in HingeConstraint. HOT 1
- RaycastVehicle: We have twice call updateWheelTransformWorld in updateWheelTransform(from updateVehicle) and then in castRay
- How can I get a list of bodies touching the line between two vectors?
- getVelocityAtWorldPoint() requires result parameter, despite returning result HOT 1
- Documentation for vectorToWorldFrame() incorrect
- Unknown Force is applied on some vertically stacked cubes on straight plane? HOT 3
- What are indices parameters of CANNON.Trimesh function?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cannon-es.