Jump to content

Crowd trigger idea


6ril

Recommended Posts

May I please pick your brain?

 

I'd like to create a crowd trigger that would activate when an agent reach its goal.

I even read in the doc : At each step in the simulation, Houdini looks at each agent and checks a series of trigger nodes (for example "distance to target > 2").

 

Unfortunately, I can't found such an option in the trigger type list : /

 

here is what I'd like:

 

my agents are walking to a target.

the target is a grid with ordered point numbers.

I set it up so that each agent seek the point matching it's agent number (agent0 goes to point0, agent1 to point1 ...)

 

at the moment when an agent reach it's point(target) it's stay there, turning on the spot with the walk animation.

So I would like to create a trigger that detect when an agent is on it's corresponding point on the grid, to switch it to the stand state.

 

thanks in advance, I'm sure it's very simple, yet I can't seem to figure it out on my own :/

 

 

*edit*

I should mention that the trigger type "object distance" isn't doing the trick. As agent would stop as soon as they get near the grid, instead of stopping when near the matching point.

 

**edit**

If only I could write simple VEX, I could use an unsafe method -> when velocity =0 then activate trigger.

but I can't :

 

// setting i@trigger to 1 will enable
// setting i@trigger to 0 will disable
i@trigger = @v=0;

 

can someone correct this ? Even tho it's very unsafe (if an agent get stuck for some reason it might change the state, right?)

Edited by 6ril
Link to comment
Share on other sites

I've posted three questions about the crowd pb I encountered, and this one is the most important.

The other two are solved, thanks to this very helpful forum :)

 

I thought this one was pretty easy for advanced houdini users, but no replies : /

 

Maybe I'm mistaken about the complexity of my pb...    (but I don't think so.)

 

 

I'll be patient  :)

Link to comment
Share on other sites

Hey Michael, thanks for your post.

 

If my timing was bad, yours is perfect! As I didn't quite solve my problem :/

 

I used Object Distance (point cloud) as trigger Type. With a small comparison distance. I thought it worked, on the large crowd, but I couldn't really see that in fact, agents are stopping (triggering) not at the right point ID, but as soon as they pass near enough any point...

 

any idea on how to to achieve what I described in the first post?

 

here is what I'd like:

 

my agents are walking to a target.

the target is a grid with ordered point numbers.

I set it up so that each agent seek the point matching it's agent number (agent0 goes to point0, agent1 to point1 ...)

 

at the moment when an agent reach it's point(target) it's stay there, turning on the spot with the walk animation.

So I would like to create a trigger that detect when an agent is on it's corresponding point on the grid, to switch it to the stand state.

Link to comment
Share on other sites

well... that was quick ! I can't.

I'm too new to all this to be able to adapt/correct your vexpression :/

 

I made a trigger, with type : VEXpression and entered this: (knowing it couldn't be that straight)

 

// setting i@trigger to 1 will enable
// setting i@trigger to 0 will disable
i@trigger = length(@P - point("../grid", "P", target_ptnum)) < tolerance;

 

but I bet I need something more like

 

if  length(@P - point("../grid", "P", target_ptnum)) < tolerance;

then i@trigger=1

 

and define target_ptnum ? as it seems to be unknown to houdini.

and define tolerance too ?

I don't even know how to do that.

 

 

 

I should have said that I'm totally new to houdini and writing VEX or any other kind of script language...

Edited by 6ril
Link to comment
Share on other sites

tried this:

tolerance = 0.5;
If  length(@P - point("../grid", "P", grid_ptnum)) < tolerance
    then i@trigger = 1;

 

 

no luck :D

 

it's telling me about the "minus" after @P -> Syntax error, unexpected '-', expecting identifier

 

 

I didn't bother posting a hip file, as my goal is very easy to describe, but if you guys thinks I should, please let me know.

 

If someone want to help with a VEXpression, the agents walk to a target named grid. all the rest is standard.

Link to comment
Share on other sites

In your case it sounds like the goal point number for each agent is the same as its own point number? So it should look like:

float tolerance = 0.5;
vector goal_pos = point("../grid", "P", @ptnum);
i@trigger = (length(@P - goal_pos) < tolerance);
  • Like 1
Link to comment
Share on other sites

thanks Cameron, I'm almost about to understand you VEXpression ! That's motivating :D

I just tried, it doesn't work.

 

so here is the file, if you have the time to look at it, thanks!

 

(might not work since I didn't include the agent folder ? )

 

 

with your last VEXpression, it gives weird results, one agent isn't even moving, and all the others reach their point, but don't trigger to the stop state (stand clip)

trigger_test.hipnc

Edited by 6ril
Link to comment
Share on other sites

I manage to achieve exactly what I want with the trigger -> object distance (point cloud), and a very very low comparison value (0.01)

so it triggers only if an agent gets very close to ANY point.

 

But,

it works because there low chance that an agent would get that near to points which aren't its goal (point with id not match the agent id).

And it works probably because I'm only testing it on a small test scene, with goal points far apart...

 

So I'm still really interested in a better true solution for the triggering method.

Link to comment
Share on other sites

Ah, it looks like the path to the grid geometry isn't quite right. You can either do "op:../../grid", since the path can also refer to files on disk, or (the better approach) use the Inputs tab to set e.g. Input 2 to the SOP path, and then use @OpInput2 in your VEXpression (see attached)

  • Like 1
Link to comment
Share on other sites

I've tried to change the path with "op:../../grid"

giving me :

float tolerance = 0.5;
vector goal_pos = point("op:../../grid", "P", @ptnum);
i@trigger = (length(@P - goal_pos) < tolerance);

 

but it's not triggering.

 

and about the better approch, I'm such a noob that I don't see any input tab :/

 

I can't ask you to teach me the entire software, you've been kind enough to work on that VEXpression for me. So I guess I'd do some more research and training, so that I'm at least able to use the provided help the forum is giving.

 

Thanks again Cameron.

Link to comment
Share on other sites

WORKS !  with this path : "op:/obj/grid"

 

Cameron, let me bow to you! ;)

 

many thanks !

 

Feel free to teach me how to add an input tho ;)

 

 

Man, that's so nice now! It will give me perfect control for my hudge crowd sim!

Link to comment
Share on other sites

brought this VEX trigger back to my bigger crowd sim, and for some reason, it doesn't work there : /

 

clueless.

 

It's a very similar setup, the only difference is the terrain (going down some stairs before reaching the level where the target grid is), and the number of agents... I think...

 

giving up for now... might investigate more tomorrow.

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...