[Closed] Maxscript & Reaction Manager
Hello everybody
I have searching the net but didn’t found any answer to my question, so i try posting here.
I want to create by using maxscript a reaction between a slider in a custom attribute and multiple weights of constraints …
I have tried this code :
ikReactor = Float_Reactor()
fkReactor = Float_Reactor()
MyObj.rotation.controller[2].weight[1].controller = fkReactor
MyObj.rotation.controller[2].weight[2].controller = ikReactor
ikReactor.reactions.reactTo d.modifiers[1].fkik.controller
fkReactor.reactions.reactTo d.modifiers[1].fkik.controller
ikReactor.reactions.setName 1 “IK”
fkReactor.reactions.setName 1 “FK”
and here what i’ve got so far :
But what I want is to have both reactor in the 2 states “FK” & “IK” and I couldn’t manage to have that. I didn’t find the command to add 2 controllers in the same state. I only be able to create some new state each time.
Here is what I would want to have :
I don’t know if I’m clear but if someone could help me, I would appreciate much !!
Thanks in advance
You have to use ‘createstate’ command by memory. By the way, reaction manager is buggy, slow and a pian to use. If you r scritping something, avoid it. there is always a solution that doesn’t use it. I have wriiten a script that does everyhing recion manger does using sript expressions.
thks for anwering me, this command doesn’t seem to work.
Yeah the reaction manager seem to be very tricky to use by scripting.
As you did, I was wondering if it will not be better to script this reaction.
But even if I have chosen a simple example here, i will have also to do some reactions with 3 or more states for each controller depending on the value of the slider.
So by the way, I haven’t found how to set by script several values to reach and just interpolate between these different states…
Yes, its called ‘createreaction’. Also use ‘setReactionState’ Thats all you need basically. Its all there in the MXS help. Scripting RM isn’t that difficult, it’s just that if speed is imortant, then use script expressions. I don’t see any need for reaction manager, I once scripted an entire facial animation rig using it and then I had to rewrite it all using script controllers when I discovered that it was too clunky and slow.
If you want to interpolate, you can use bezier function…but this is a little more advanced.
By the way, I’m puzzled why you’d search the net before searching the mxs help…
Of course I have searched the mxs help before searching the net and before posting here !
As I said, I was only able to create some new state each time.
I meant, I was using these commands “createreaction” or “setreactionstate”; but for example what results by using this method is :
ikReactor = Float_Reactor()
fkReactor = Float_Reactor()
MyObj.rotation.controller[2].weight[1].controller = fkReactor
MyObj.rotation.controller[2].weight[2].controller = ikReactor
ikReactor.reactions.reactTo d.modifiers[1].fkik.controller
fkReactor.reactions.reactTo d.modifiers[1].fkik.controller
ikReactor.reactions.setName 1 “IK”
fkReactor.reactions.setName 1 “FK”
createreaction ikReactor
setReactionState ikReactor 1 80
setReactionState ikReactor 2 50
ikReactor.reactions.setName 2 “FK”
and not only one state “IK” and one state “FK”…
I know reactions slow down the whole thing, but i will not have so many to set up. And as you said, defining a bezier function is a little bit advanced
instead of :
createreaction ikreactor
setReactionState ikReactor 1 80
setReactionState ikReactor 2 50
try:
createreaction ikreactor
setReactionState ikReactor 1 80
createreaction ikreactor
setReactionState ikReactor 2 50;
At least that’s what i did in my ancient script that worked, at least.
I don’t know if the order makes any difference anyway.
I mean – forget about trying to get things to look like they do in the reaction manager UI. I gave up on that, by memory.
As long as it works, who cares about getting things to look like they do in the UI window. RM is dodgy anwyays…
the reaction manager itself and the reactor controller is very buggy. i had many issues with it. like: #garbage data in the dialog, #loosing connections on undo/redo, #loosing connections with merge, etc.
so i recommend to not use it.
here is a sample how to do ‘blend’ control using the parameter wiring:
blendAttr = attributes blendAttr
(
parameters params rollout:params
(
blend type:#float default:50 animatable:on ui:(ui_blend_sl,ui_blend_sp)
)
rollout params "Parameters"
(
slider ui_blend_sl range:[0,100,50] type:#float width:102 align:#left offset:[-10,-10] across:2
spinner ui_blend_sp range:[0,100,50] type:#float fieldwidth:46 align:#right offset:[6,0]
)
on create do
(
blend.controller = Bezier_Float()
)
)
delete objects
t1 = dummy name:"target1" pos:[-20,0,0] boxsize:[5,5,5]
t2 = dummy name:"target2" pos:[20,0,0] boxsize:[5,5,5]
s0 = dummy name:"source" pos:[0,0,0] boxsize:[10,10,10] isselected:on
custattributes.add s0 blendAttr baseobject:on
c = s0.position.controller = Position_Constraint()
c.appendTarget t1 50
c.appendTarget t2 50
paramWire.connect s0.baseobject.blendAttr[#blend] c[1] "Blend"
paramWire.connect s0.baseobject.blendAttr[#blend] c[2] "100.0-Blend"
The thing is if i try smthg like that :
ikReactor = Float_Reactor()
MyObj.rotation.controller[2].weight[2].controller = ikReactor
ikReactor.reactions.reactTo $dfsd_foot_ctrl_R.modifiers[1].fkik.controller
createreaction ikreactor
setReactionState ikReactor 1 80
createreaction ikreactor
setReactionState ikReactor 2 50
the result looks like that because when I assign the controller, a first state is automatically created :
Yeah – what denis said. he’s the man when it comes to mxs.
Forget about the UI. RM is buggy.
edit***
Is the rig behaving as expected or not? Check values in listener
yes the UI is really buggy, doesn’t matter. It’s gonna be a total mess but who cares …
Denis thanks for your script. Working very well, and could be very useful for me. But it works for two targets in this example. But if I have got 3 or more targets, how should you blend the positions ?