[Closed] Crowd Cognitive Controllers
hi,
im making a really simple little crowd sim at the mo and im not having much luck with the scripting of the cognitive controllers.
heres the situation:
two teams of 4 delagates
- one called bob
- one called tim
they both start off woundering until two delagates from either side come too close to each other and they stop.
so far i’ve got them following surface plane.
i’ve put in a script to go from the state of woundering to a state of avoiding (i cant seem to make them stop and stand stil)
heres the code:
fn closeness del t = (
get_dist=distance del.simpos $bobs.simpos
print (get_dist)
if get_dist < 20
then 1 else 0 )
any ideas on what im doing wrong or any books or websites on cognitive controller scripting would be greatly welcome.
cheers
The script looks right (you are measuring distance of each delegate to bobs everytime, so this scrìpt can control all delegates but bobs).
But it’s not enought, please show the states too.
Fernando
ok i’ll give ya a complete break down of the delagates and states ect:
two teams
team “bob”
-bobs
-bobs01
-bobs02
-bobs03
-bobs04
Team “Tim”
-Tims
-Tims01
-Tims02
-Tims03
-Tims04
Each team has its own cognitave controller on it both the same but with the setting tweaked to avoid or seek out the other team.
Tims Controller
State 1 – “Wander” :
- wander
Cognitave controller doing the transistion between them
State 2 – “run away from bob”
-Repel bobs
Bobs controller is basicly the same but i’ve not done any scripting on that as i wanted it to work on one team before i did the other.
The script i wanted to measuer the distance between each of the tim delagates to each of the bob delagates. so if a bob delagete gets too close to a tim delagete, then that tim delagete then returns true and goes onto the next state
Assuming this is part of the congnitive controller applied to Tim team:
get_dist=distance del.simpos $bobs.simpos
This measures the distance between each delegate of Tim team and the object named bobs. Not with each one of bob team.
Fernando
so how could i change it to measure the distance between each of the memebers of the tim team and each of the members of the bob team?
You cand do a for loop with all the delegates and check if belongs to one team, but
I guess you are missunderstanding congnitive controllers.
Why do you want to know at the same time the distance between one delegate and all the others? May be it’s close enougth to one and not to the other…
Fernando
[size=2]The crowd helpers name is Crowd01 and the first team in it is bobs.[/size]
[size=2]To check the distance between the evaluated delegate and each one belonging to this team:
[/size]
for memb in $Crowd01.teams[1].members do get_dis = distance memb.pos del.pos
Fernando
i problay am really miss understanding cogntive controllers and what they do, but to me it seemed logical to use them to test distance between delagtes of team A and team B and have thoes two delagtes that are a certain distance apart to do something together such as shake hands or fight.
would this be better suited in a scripted behavour?
Hi Jifman,
I guess that instead of cognitives, it’s better to use a Per Frame Function (with the crowd helper selected: Modify > Solve > Maxscript > Edit Maxscript).
Each congnitive controller would be checking distances in a for loop for each delegate at every frame…
A Per Frame Function will check only once.
If it detects one close enough to other, that’s the moment to operate on both.
Fernando
ok, i think i get what you mean. but how would i change the states of the delagetes that were close?
give them both the same veribal in the per-frame script witch could be used in with a cogenative controller to go from a wounder state to a seek state or a handshake state or could that all be done within the per-frame script?