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

Getting NaN when following instructions for Node.js implementation #200

Closed
mrmckeb opened this issue Jan 31, 2016 · 5 comments
Closed

Getting NaN when following instructions for Node.js implementation #200

mrmckeb opened this issue Jan 31, 2016 · 5 comments

Comments

@mrmckeb
Copy link

mrmckeb commented Jan 31, 2016

We've been trying to get this working server-side in Node.js, and for some reason movements are resulting in NaN for x/y positions. We used the code example provided here: #101 (comment)

CodePen example: http://codepen.io/anon/pen/dGKeJq

Sorry if this is just something silly we missed, but after a lot of fiddling, I can't work it out.

@caoakleyii
Copy link

I am also receiving this same issue, it seems to only happen after the initial engine tick.

@liabru
Copy link
Owner

liabru commented Feb 7, 2016

This is because engine.timing.delta is no longer defined, it was moved to Matter.Runner.
The solution here is to pass a defined value for delta e.g.:

 Matter.Engine.update(engine, 16);

See the docs for Matter.Engine.update.

@liabru liabru closed this as completed in 490d232 Feb 7, 2016
@liabru liabru removed the investigate label Feb 7, 2016
@mrmckeb
Copy link
Author

mrmckeb commented Feb 8, 2016

Thanks @liabru, I'll get moving with this project again ;)

@Shadowstep33
Copy link

I am experiencing a similar issue. angle and some other angle related properties, as well as axes, all are plagued by NaN. I have at least narrowed down the problem to one of these lines of code:

                        Body.setVelocity(buckets['walking'][b].body, {
                            x: x_move,
                            y: y_move
                        });
                        Body.setAngle(buckets['walking'][b].body, 0);
                        Body.setAngularVelocity(buckets['walking'][b].body, 0);
                        Body.setInertia(buckets['walking'][b].body, 0);

When I comment out setAngle, setAngularVelocity, and setInertia, i no longer get the NaN problem but the bodies do not move as I want them to. buckets.walking[b].body isStatic = false (when I set it to true, but leave all code intact no problem arises).

EDIT: I Just pulled the lastest build to make sure it wasn't an outdated problem

@liabru
Copy link
Owner

liabru commented Feb 18, 2016

@Shadowstep33 is this on node or in the browser? Do all of those setters cause NaN or can you narrow it to one? Can you try debugging and stepping through?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants