Jump to content
Atom

[SOLVED] Controlling Crowd Agent Speed Using VEX?

Recommended Posts

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

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

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 2

Share this post


Link to post
Share on other sites

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 2

Share this post


Link to post
Share on other sites

Hi Atom,
that is very cool!
thank you for that
can you please explain where do you create the "@group_slow_erea"  attribute?
is that on the box geo that triggers the change?

Thanks
G

Share this post


Link to post
Share on other sites

@group_slow_area is not an attribute. You use "@group_" as a prefix to reference a group. The group is actually named "slow_area".

Place a PopGroup after your crowdsouce and fetch in your grouping geometry using the Bounding tab to specify the SOP path to the box.
 

 

Untitled-1.jpg

Share this post


Link to post
Share on other sites

I'm actually getting an error when adding this snipet to the crowd state
any idea why? am I doing something wrong? I've added the pop group like in your example.

Thanks
G


vexError.jpg.c1f76c57565b895629176d642c70bd8f.jpg

Share this post


Link to post
Share on other sites

A VEXpression is different than a PopWrangle. In a VEXpression, you assign attributes to interface controls. Hover your  mouse over the interface element you want to control and read the label. That is the name of the variable that you can reference inside the VEXPresion code block.

In your posted image, this could work.

clipspeedmultiplier = length(v@v);

I don't think VEXpressions can write to attributes, but they can read them.

Edited by Atom

Share this post


Link to post
Share on other sites

thanks!

and if I want to use a PopWrangle I plug it after the state node?

Thanks
G

Share this post


Link to post
Share on other sites

Here is my node network.

Untitled-1.jpg

Edited by Atom

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

×