ah-fx Posted September 16, 2016 Share Posted September 16, 2016 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. Adam Quote Link to comment Share on other sites More sharing options...
Atom Posted September 16, 2016 Share Posted September 16, 2016 (edited) 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@trigger=1; } 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 September 16, 2016 by Atom Quote Link to comment Share on other sites More sharing options...
ah-fx Posted September 17, 2016 Author Share Posted September 17, 2016 Ah ok that will do the trick. Thanks Atom Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.