Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matter-js npm simply won't work #960

Closed
DkeRee opened this issue Jan 26, 2021 · 4 comments
Closed

matter-js npm simply won't work #960

DkeRee opened this issue Jan 26, 2021 · 4 comments

Comments

@DkeRee
Copy link

DkeRee commented Jan 26, 2021

Alright, this is the first time I've tried leaving an issue so this will be a new experience for me xD

I tried using the matter-js npm to make a multiplayer game but....

[Error: Cannot find module 'poly-decomp']

I believe that this is a problem in matter-js itself and if anybody can shine some light into this situation it would be much appreciated. I'm using version ^0.16.0 according to the package.json

@liabru
Copy link
Owner

liabru commented Jan 26, 2021

Where / when are you seeing this? What does your build config look like?

The solution is to npm install poly-decomp --save, see existing issues #949 and #559

@DkeRee
Copy link
Author

DkeRee commented Jan 27, 2021

Thanks man. I love how you are so responsive. I got it working! However, since you're here I got a new problem lol. It is server side and I used the npm. I tried emitting socket events with keycodes that the server would watch for and then "move" the corresponding body that way. I tried to use Matter.Body.translate() and it worked, but it kinda "forced" the body into the other body which made them spazz. Thus, I looked at my friend's repl and heused Matter.Body.applyForce(). I tried to use it, but it didn't work. When console logging the body.force in his repl, I noticed how the force object {x: 0, y: 0} fluctuates from 0 when force is applied, signifying how much force is applied to each side and that it goes down back to 0 because the force has been well, applied and it stops. However, in my case when console logging the body.force, it ADDS UP and the force is never applied. For example, I tried adding -0.5 to the y force whenever I held down the "w" button. It should have showed the y flucuating from 0 to -0.5 but instead it kept adding up and never got applied. So if I kept holding down "w" it would eventually add up to 100+ y force and never gets released.

@DkeRee
Copy link
Author

DkeRee commented Jan 27, 2021

Another quick update:
Figured that it was because I wasn't calling Matter.Engine.update(), but even after that didn't work.

var tickrate = 1000/60;
Matter.Engine.update(engine, tickrate);

It just simply still kept adding up. Also server side still.

@liabru
Copy link
Owner

liabru commented Feb 12, 2021

See my latest post on #559 for an update on this and please use that thread if you have further comments on this.

For any other unrelated issues please open a new thread, thanks again for reporting this.

@liabru liabru closed this as completed Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants