Sign in to follow this  
_Kami_

How to apply randomness in an impact?

Recommended Posts

Lets say I have two points x, y to apply the force between them i take the vector of the two points and i multiply it by some force. What if I want to apply some randomness in degrees? This is what i have now:
// no y force, already added.
Vector3_t cHorizontal(  vX1-vX2,0,vY1-vY2);
int nRandomDir = (rand() % (nHorizontalRandomness*2)) - nHorizontalRandomness;
// where to apply randomDir?
cHorizontal.Normalize();
cHorizontal *= vImpactNeeded;
Impact(cHorizontal);

[Edited by - _Kami_ on September 2, 2004 4:48:09 AM]

Share this post


Link to post
Share on other sites
ok, this is what I came up with.. Hope this can help some others as well:)


float vDir = 45.0 * 3.14 / 180.0; // to radians
Quaternion_t cRot(Vector3_t(0,1,0),vDir);
cHorizontal = cHorizontal * cRot;
cHorizontal.Normalize();
cHorizontal *= vImpactNeeded;

Share this post


Link to post
Share on other sites
There is no such thing as randomness in impact, every collision, every force, every velocity can all be modelled by physics. there is such a thing as odd-shaped objects that do bounce funny & we would have a hard time designing up a physics model for them. but if you simply using spheres... its very simple, every entity has rotational & translational kinetic energy & there is potential energy too. Do you need help with a good model?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this