Jump to content
Atom

[SOLVED] Controlling Crowd Agent Speed Using VEX?

Recommended Posts

Posted (edited)

Does anyone know hot to alter the @gait_speed attribute, using VEX, found under ClipProperties? By default, the PopWrangle can only modify Geometry based attributes.

Untitled-1.jpg

Edited by Atom

Share this post


Link to post
Share on other sites
Posted (edited)

Even the concept of controlling velocity seems to be messed up. Here you can see my agent stops forward motion when I explicitly set velocity to 0.

crowd_slow_area_STOPs.gif.90e3648d947867b7c3e36e159df43d89.gif

 

And here I don't see any slow down when I greatly reduce velocity via multiplication. I expected to see some slowdown in movement along the Z axis

crowd_slow_area2.gif.8a7dcee75d19f3dc507e0a198cc4506d.gif

 

I am able to affect clipspeedmultiplier, on the CrowdState node itself, when my agent passes through the box area.

crowd_slow_area.gif.ef3ff5d20f17b01e397ba6cfbba72083.gif

if (@group_slow_area==1) {
    clipspeedmultiplier = 0.25;
} else {
    clipspeedmultiplier = 1.0;
}

But I also want to cause the forward speed to slowdown as well. Velocity is a read-only attribute in this CrowdState Vex code snippet context or I could try...

if (@group_slow_area==1) {
    clipspeedmultiplier = 0.25;
    v@v *=0.25;
} else {
    clipspeedmultiplier = 1.0;
    v@v *=1.0;
}


So the above code is the intention, but how to implement it in the DOPs network?

 

Edited by Atom

Share this post


Link to post
Share on other sites
Posted (edited)

Ok, I think I have figured out a bit of the problem. Basically you need to turn off Limit Particle Speed To Gait Speed Range on your Crowd State nodes if you plan on controlling the velocity directly with VEX.

Here is a slowdown based upon recursively reducing velocity until the agent nearly stops.

if (@group_slow_area==1) {
    v@v[2]*=0.998;
} else {
    v@v=set(0,0,1);
}

crowd_slow_area.gif.52f4a7299eaead529158c9a9d75828f6.gif

 

Here is a slowdown based upon a direct setting of the velocity value.

if (@group_slow_area==1) {
    v@v=set(0,0,0.25);
} else {
    v@v=set(0,0,1);
}

crowd_slow_area_set.gif.ac07ec38823c5287ce6fb7dc966600b8.gif

Edited by Atom
  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

Skating is the result of the ClipSpeed being out of synch with the particle velocity. To remove the 'skating' you see in the recursive velocity reduction, shown above, you must add a new attribute to the agent to remember what the last speed multiplier was set to.Then the clip speed will slow down in the same manner as the velocity. A 'truer' slow motion.

PopWrangle code.

if (@group_slow_area==1) {
    v@v[2]*=0.998;
    f@last_speed_multiplier *= 0.998;
} else {
    f@last_speed_multiplier = 1.0;
    v@v=set(0,0,1);
}

VEX Code Snippet on CrowdState

if (@group_slow_area==1) {
    clipspeedmultiplier = f@last_speed_multiplier;
} else {
    clipspeedmultiplier=1.0;
}

 

crowd_slow_area.gif

Edited by Atom
  • Like 1

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

×