Jump to content

accessing crowd's point attributes to add custom forces/velocity

Recommended Posts

Hi guys,

Is there any way to access point attributes in crowd setup to tweak the ragdoll behaviour?

popforce seems to break the whole thing and each agent is processed as a single point but somehow still able to run bullet sim in ragdoll state but with limited capability.


Thank you



Share this post

Link to post
Share on other sites
s@name = "piece_" + itoa(@ptnum);
//Randomize Velocity
float x,y,z,minX,minY,minZ,maxX,maxY,maxZ,sx,sy,sz,sminX,sminY,sminZ,smaxX,smaxY,smaxZ;
//source min max velocity
vector min=chv("minVelRandom");
vector max=chv("maxVelRandom");
//randomize min max velocity
x = fit01(rand(@ptnum),min.x,max.x);
y = fit01(rand(@ptnum*222),min.y,max.y);
z = fit01(rand(@ptnum*333),min.z,max.z);
//assign the same to force which doesnt work
//assign the random velocity to each bone which worked for me
i@myBones= agenttransformcount(0, @ptnum);
for(int i;i<=@myBones;i++)
//Initial Spin Random
vector smin=chv("minSpinRandom");
vector smax=chv("maxSpinRandom");
sx = fit01(rand(@ptnum*1000),smin.x,smax.x);
sy = fit01(rand(@ptnum*1222),smin.y,smax.y);
sz = fit01(rand(@ptnum*1333),smin.z,smax.z);
//assign Spin Random in Torque

//Oscilation Setup
//In the below vex code the only value I have used in the simulation is the v@oscillation's Y component but the code also creates an array which is currently not being used

/*vector oMin         =   chv("oscillationMin");
vector oMax         =   chv("oscillationMax");
vector oRandom      =   fit01(random(@ptnum),oMin,oMax);
v@oscillation       =   oRandom;
v@zeroOscillation   =   set(0.0,0.0,0.0);

i@myBones= agenttransformcount(0, @ptnum);
for(int i;i<=@myBones;i++)
//Create v_agent array and a vector array for oscillation of certain selected bone numbers

The above code will create some custom velocity for the agents in sop level and then later you can use the v[]@v_agent in a sop solver to copy to the particular agents you need to apply it to. So basically what we are are doing here is defining random velocity and torque to a certain number of bones in the crowd agents. You should feel free to bypass the codes that you do not need. I have already bypassed the oscillation bit of the code for you.


Manishkumar Makhija

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