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

anyway to change the mass of all piece #9

Open
badrshs opened this issue Aug 1, 2018 · 1 comment
Open

anyway to change the mass of all piece #9

badrshs opened this issue Aug 1, 2018 · 1 comment

Comments

@badrshs
Copy link

badrshs commented Aug 1, 2018

Hi , is there is anyway to change the mass of all generating piece ?

as I found , the mass of each piece will be 1 as default , I want to decrease the number to something like 0.01 ?

Updated:

thanks , I got the idea , I didnt notice that the pieces are under the main object , I thought it will be " real time rendering "
awesome package
close it ❤️

@devingDev
Copy link

change the script to your liking. its all open source as far as i see.

in explodable.cs
in the routine
private void generateFragments()

you can get the rigidbody2d component where he is looping through the created fragments and assign the rigidbody2d values.
or you can write another function to loop through all of them.

`public void fragment(float gravityScaleOfPieces = 0.0f)
{
if (fragments.Count > 0)
{
deleteFragments();
}
//if fragments were not created before runtime then create them now
if (fragments.Count == 0 && allowRuntimeFragmentation)
{
generateFragments();
foreach (GameObject frag in fragments)
{
Rigidbody2D r = frag.GetComponent();
if (r != null)
{
r.gravityScale = gravityScaleOfPieces;
}
frag.transform.parent = transform;
frag.SetActive(false);
}
}

}`

here is what i did to automatically set their gravity so they dont act on their own . I call this when I want to make it exlpode.

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

2 participants