Jump to content
Sign in to follow this  

Crowds - Killing agents and capturing attributes

Recommended Posts

Hey guys,

Im working on a crowd system and I would like to kill agents when they collide with a static object, and then transfer all of their attributes and geometry to a new primitive to use in another simulation. I've tried two approaches so far, but neither give the result I am after so far. Please let me know if there is a simpler way to go about this.

One is to use a crowdtrigger with the type of RBD Impact Data and then transition my agents into a "Dead" clip/state. To get this functioning, it seems I need my Crowd State RBD Ragdoll mode on Animated Static, but when I set this a bunch of my agents disappear, and the collisions don't seem to be very accurate. I'm sure I can get around both of these issues, but the real problem with this method is that when my agent dies I would like to capture his current state and the current frame of his clip, and not have to move it into a new one.

The second method is to use a popkill and then create a new point and transfer attributes when the original particle is dead. This kind of works, but it may be a lot of work to rebuild the geometry to match the original crowd prim. It needs to be a packed prim, it has some index paired attributes, and some other attributes which I seem to be only able to access via agent* vex functions.



Share this post

Link to post
Share on other sites

One approach I use is to run the CrowdTrigger in CustomVEXpression mode. This way I can control the transition directly and I have access to all the agent attributes. The CrowdTrigger is an HDA that you can unlock for editing. If you dive inside and take a look at the rbdimpactdata option you'll see it is just a PopWrangle with some vex code. You can copy that code logic up one level, to emulate that style in a CustomVEXpression mode. This way you can keep that functionality and extend that code to accomplish your custom goals.

Here is a way to make two new attributes on an agent to store the state and clip frame. I am not actually sure if cliptimes is frames or seconds so you may have to come up with a conversion for that value.

if (some_flag_determines_collision) {
    s@final_state = s@state;
    f@final_clip_frame = f[]@cliptimes[0];


I think you generally want to avoid setting the @state directly. If your timing and code is not 100% synched and perfect you will experience a "popping" of poses into the directly assigned state.

What I do I setup a single CrowdTrigger in VEX mode that triggers nothing and acts as a render loop would in a game engine. It is dedicated only to reviewing clips and states and setting other attributes that the CrowdTrigger themselves will review to determine i@trigger values. I place it first in the list on the merge_transitions node. This effectively makes it a "pre-processor". You can place it last in the list for "post-processing" too. By having code that runs before any of the other CrowdTriggers you can be sure that the attributes they are going to evaluate are "fresh" for that frame.

So in the above example code instead of saving the final_clip_frame you would assign a new attribute @pending_state = "dead_pose"; or something similar. Then the review  VEX code will examine @pending_state for all agents and determine what state they should transition into at any given time. This allows you to defer processing for a frame and safely transition to a final state.




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
Sign in to follow this