Advertisement

How to apply randomness in an impact?

Started by September 02, 2004 03:03 AM
2 comments, last by Luke Miklos 20 years, 3 months ago
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]
www.ageofconan.com
[img=http://www.tkoc.net/rotation.jpg]

http://www.tkoc.net/rotation.jpg

Here you can see a drawing of it.. maybe easier to understand then.
www.ageofconan.com
Advertisement
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 radiansQuaternion_t cRot(Vector3_t(0,1,0),vDir);cHorizontal = cHorizontal * cRot;cHorizontal.Normalize();cHorizontal *= vImpactNeeded;
www.ageofconan.com
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?
Whatsoever you do, do it heartily as to the Lord, and not unto men.

This topic is closed to new replies.

Advertisement