Giter Site home page Giter Site logo

Comments (6)

anemol avatar anemol commented on May 25, 2024 1

Thanks for your help.

from cannon-es.

marcofugaro avatar marcofugaro commented on May 25, 2024

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.

anemol avatar anemol commented on May 25, 2024

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});

Capture d’écran_2020-07-01_14-11-02

from cannon-es.

marcofugaro avatar marcofugaro commented on May 25, 2024

Yeah sure it looks correct! Here is a ConvexPolyhedron in the examples.

https://github.com/react-spring/cannon-es/blob/06a34a6e4fca577440f759530fecbb76eaab0d97/examples/convex.html#L19-L42

Could you maybe make a screencast of the problems you're having?

from cannon-es.

anemol avatar anemol commented on May 25, 2024

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.

marcofugaro avatar marcofugaro commented on May 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.