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.Body.setStatic() - setting to false after already true removes body #187

Closed
dvulanov opened this issue Dec 29, 2015 · 12 comments
Closed

Comments

@dvulanov
Copy link

I would like to be able to toggle a body between static and non-static, but it looks like once a body is set to static un-setting it messes something up and the body disappears from the render view.

Should it be possible to use setStatic in this manner? I'm using latest build (2015-12-23).

Thanks!

Dan

@dvulanov
Copy link
Author

Ok, looks like resetting the body's mass to something non-static (i.e. non-infinity) does the trick. This allows me to use Matter.Body.setStatic() in a way where I can toggle a body's static property.

thanks,
Dan

@liabru
Copy link
Owner

liabru commented Dec 29, 2015

It's a known limitation that you can't unset static once it's been set. The reason is that it requires certain properties to be set to Infinity (e.g. mass) which means the old value is lost.

A possible fix is to add some sort of property cache to bodies so they can be restored, but this is currently a low priority.

If you need this, you should be able to look at Body.setStatic and do something similar for your own project though.

@dvulanov
Copy link
Author

Perfect, will do.

@EzraLopez
Copy link

Was this ever solved?

@liabru
Copy link
Owner

liabru commented Jun 9, 2016

Not implemented yet but in the meantime you can implement your own based on my previous comment, I'll look at this again soon.

@ghost
Copy link

ghost commented Sep 25, 2020

can someone help me to change isStatic:true; to isStatic: false on click of down arrow.
please help..

@ozgur-can
Copy link

can someone help me to change isStatic:true; to isStatic: false on click of down arrow.
please help..

you can use eventListener to change static status with Body.setStatic(obj.body, false/true);

@ghost
Copy link

ghost commented Oct 19, 2020 via email

@parthsharma365628
Copy link

can someone help me to change isStatic:true; to isStatic: false on click of down arrow.
please help..

me too

@liabru
Copy link
Owner

liabru commented Feb 14, 2021

@parthsharma365628 did you try Body.setStatic?

@ghost
Copy link

ghost commented Feb 15, 2021 via email

@jivishghai1109
Copy link

how to collide two bodies one static one non static

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

6 participants