Giter Site home page Giter Site logo

Comments (10)

namel avatar namel commented on May 8, 2024

Hi,

That's pretty cool. 200 objects is actually quite high for lance, I don't think we've ever experimented with that many objects, so you may well have run into a limit which I am unfamiliar with and needs digging into.

The tougher problem though is that DynamicObject is designed specifically for the SimplePhysicsEngine, and you may not be able to inherit from it. A better way to start working on matter.js is to write a different class which inherits directly from GameObject, and is implemented in the style of PhysicalObject. You could call it PhysicalObject2D.

In this newer pattern which we used in PhysicalObject, each game object has a corresponding physical asset inside the physics engine, which it calls this.physicsObj. The physics engine is responsible for maintaining the position, orientation, velocity, and angular velocity of the physicsObj. refreshFromPhysics() and refreshToPhysics() are methods of the game object, exactly as you wrote them. And in this scenario, the physics engine (matter) should update the physical asset, and refreshFromPhysics() will be called to collect the new position, orientation, velocity, and angular velocity values.

The physics engine does not need to be deterministic. The client and server values are expected to diverge, and the bending algorithm should be able to adjust the client values back to the server values asymptotically.

The only other comment is that you should be working with the develop branch of lance if possible. Please join our slack channel to keep us up to date on your progress.

from lance.

AskingQuestions avatar AskingQuestions commented on May 8, 2024

@namel

Ok that makes sense. Ill learn more about PhysicalObject and switch over.

I will have to do some more profiling on lance objects, and look into the 5s step(I saw that the bulk of the 5s was taken up by an indexOf call?)

Another question, does lance only send objects to the client if they have changed, or does it always send everything?

Thank you so much for your time.

from lance.

kanecko avatar kanecko commented on May 8, 2024

@namel you say that "200 objects is actually quite high for lance". Did you mean that in the context of using a physics engine, or in general?

from lance.

namel avatar namel commented on May 8, 2024

Closing this one, PhysicalObject2D now exists in the develop branch

from lance.

josiahbryan avatar josiahbryan commented on May 8, 2024

@namel @AskingQuestions - did you ever get MatterJS integrated with Lance? I'm using MatterJs client-side, but I'd love to use Lance with it...

from lance.

namel avatar namel commented on May 8, 2024

Not integrated at the moment. Are there any specific features which MatterJS has, and P2 doesn't? Or is it just for convenience?

from lance.

AskingQuestions avatar AskingQuestions commented on May 8, 2024

@namel @AskingQuestions - did you ever get MatterJS integrated with Lance? I'm using MatterJs client-side, but I'd love to use Lance with it...

I had it working, but the performance did not suit my needs. However, if you're not stressing the network too much MatterJS is great (I don't think I tried more advanced objects like cloth, or soft bodies.)

I might be able to dig up the code and post it here if you want. (It was a year ago so things could be broken.)

from lance.

josiahbryan avatar josiahbryan commented on May 8, 2024

@namel @AskingQuestions - thanks for the input, gents. @namel - more the "cost of conversion" - doing a basic game, and hope to add "multiplayer" to http://kpxtest.surge.sh/ - just a silly little blocks game. Not worth my time to convert it right now to another physics engine, not to mention, an entirely new build stack (webpack vs babel) and UI (uses React for other stuff in the app and I don't feel like setting up tooling - create-react-app did the tooling and I'm just using their build scripts.) So it's not really just the physics engine - it's having to convert physics + build pipe + UI to "something else" - and that's too much right now. Just trying to find a "pluggable" physics networking solution, and if it was just the physics engine, I might change. But after reading more, I'd have to rewrite the ENTIRE app - from the ground up - due to the isomorphic nature of lance. ALLL this is not meant to be judgemental - it's TOTALLY AWESOME what you've done here with lance - VERY impressed. I just can't "afford" to switch the existing codebase, so sorry!! Keep up the good work though! Seriously, awesome project here.

from lance.

namel avatar namel commented on May 8, 2024

Got it. It is a lot of work switching from single-player to multiplayer. From my experience with Asteroids, it seems like doubling the effort.
@AskingQuestions if you have the code lying around somewhere, I'll gladly include it.

from lance.

AskingQuestions avatar AskingQuestions commented on May 8, 2024

Got it. It is a lot of work switching from single-player to multiplayer. From my experience with Asteroids, it seems like doubling the effort.
@AskingQuestions if you have the code lying around somewhere, I'll gladly include it.

@namel

I just looked over the code, (26 lines) and it barely implements the most basic MatterJS bodies. (Never got around to adding more.)

from lance.

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.