View Full Version : assign behavior to delegates
04-18-2008, 04:43 PM
i have a problem with assigning a behavior to a delegate with maxscript...just dont know the right way. i went through the reference more than one time, but it ist totally not clear to me.
When i try:
$Crowd01.behaviors = #(Wander_Behavior)
i got the error, that "Wander_Behavior" could not be converted to MaxObject.
so...i hope you can help me :)
04-19-2008, 08:36 AM
the Avoid_behavior is a constructor , this means that either you supply the parameters or you supply empty brackets ()
its just like a box , you don't get the box created if you typed box , you type box()
however this also doesn't work ! , assuming your crowd is in variable crow_01
if you type crow_01.behaviors = Avoid_behavior() --- it doesn't work aslo !
the method you use is like asking the crowd system for what behaviors does it contain
but you use it as assignment , that's why it doesn't work
crow_01.behaviors return an array of what is there , but doesn't assign any thing
as you know , you add to arrays by the append command
so you shoud append that empty array with the behavior you have created
here is a part of a thing i was doing , i commented some stuff , and included the team part
hope its of any use
box name:"Target" pos:[250,800,0]
Sphere name:"__S" ishidden:true segments:40 radius:100
delegate size:0.02 xyconstraint:false
m=crowd name:"First_Crowd" pos:[0,-170,90]
m.scatter.positionspace = 2
m.scatter.positionobject = $__S
m.scatter.cloneobject = $delegate01
m.scatter.numclones = 19
-- you can add the orientation and generate it for the delegates
Beh_01 = Avoid_Behavior() -- you have to create it first
append m.behaviors Beh_01-- then you assign the behavior to the crowd system
Beh_02 = Seek_Behavior()
append m.Behaviors Beh_02
team_01 =CrowdTeam() --empty constructor
team_01.name = "Team1" -- the name of the team (parameter)
team_01.members = $delegate* as array --the result of this array is the team members
append m.teams team_01 -- we add the array of crowd teams (which is empty) the team we created
assin_01 = crowdassignment team:team_01 behavior:Beh_01 active:true--this is the constructor but with some parameters
assin_02 = crowdassignment team:team_01 behavior:Beh_02 active:true--the same here
append m.assignments assin_01 -- assign the crowd the crowd assignment !
append m.assignments assin_02 -- again the same thing
max tool zoomextents --just to see things
04-19-2008, 06:38 PM
thank you very much! that really helps...thanks!
04-19-2008, 06:38 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.