Skip to content

Instantly share code, notes, and snippets.

@iofractorg
Created July 17, 2022 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iofractorg/9991273c087508e33521210aac1f0f7e to your computer and use it in GitHub Desktop.
Save iofractorg/9991273c087508e33521210aac1f0f7e to your computer and use it in GitHub Desktop.
void SetMass(int newMass)
{
_mass = newMass;
m_Mass = newMass;
float scale = newMass * 0.01f;
transform.localScale = new Vector3(scale, scale, 1);
rb.sharedMaterial = frictionMaterial;
if (newMass >= 250)
{
angularVelocity = 250 - newMass * 0.35f;
if (angularVelocity < 130 && newMass <= 300)
angularVelocity = 130;
else if (angularVelocity < 80)
angularVelocity = 80;
}
else if (newMass >= 180)
{
angularVelocity = 400 - newMass;
}
else if (newMass >= 100)
{
angularVelocity = 600 - newMass;
}
else
{
rb.sharedMaterial = highFrictionMaterial;
// I don't know what I'm doing because I suck at math
// so I just gave up and just decided to do the above
/*float moreSpeed = 0;
int remainingMass = newMass;
while (remainingMass > 0)
{
// idk what I'm doing I suck at math lol
moreSpeed += 1000 / remainingMass;
if (remainingMass > 80)
remainingMass -= 4;
else if (remainingMass > 55)
remainingMass -= 2;
else
remainingMass -= 1;
}*/
angularVelocity = 4000 - newMass * 40;
}
// Make sure dice spin in correct direction
angularVelocity *= -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment