Jump to content

[SOLVED] Controlling Crowd Agent Speed Using VEX?


Atom

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
Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
Share on other sites

  • 2 years later...

@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

Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...