MadMax50 Posted January 13, 2019 Share Posted January 13, 2019 hello, I am trying to get a nested if statement to work properly in sops. First I have my constraints being deleted by the Y value then if the Y value is less than a certain value , I want to set @strength=-1 based on a random condition. Then i want to delete all the constraints that are not @strength=-1 The result should just be only the constraints that are @strength=-1 if it is below a certain @P.y value. I am not sure what I am doing wrong here... float myRand= rand(@primnum*234.234); f@strength=100; if(@P.y<chf("Thresh_Y")){ if(myRand>chf("Thresh")){ f@strength=-1; if(f@strength>0){ removeprim(0,@primnum,0); } } } I will also attach my scene file for anyone that wants to take a look Thank you. nested_if_statements.hipnc Quote Link to comment Share on other sites More sharing options...
Sepu Posted January 13, 2019 Share Posted January 13, 2019 If I understood you correctly this is what you want, I put color instead of deleting so you can see what is happening. Add the removeprim function where @Cd is or put a blast at the end "@strength==-1" and check delete non selected. float myRand= rand(@primnum*234.234); f@strength=100; if(@P.y<chf("Thresh_Y")){ f@strength=-1; @Cd = {1,0,0}; } else if (myRand>chf("Thresh")) { f@strength=-1; @Cd = {0,1,0}; } Quote Link to comment Share on other sites More sharing options...
MadMax50 Posted January 13, 2019 Author Share Posted January 13, 2019 @SepuThank you. I am trying to keep f@strength=-1 and delete everything else when it gets below a certain Y value. Basically i am trying to achieve an rbd sim that breaks below a certain Y value but some pieces stay together. I'll attach my scene with the simple rbd sim to show you what I mean. I implemented your method into it but I am not sure how I will achieve this without another if statement in there. Thank you. nested_rbd.hipnc Quote Link to comment Share on other sites More sharing options...
anim Posted January 13, 2019 Share Posted January 13, 2019 this: float myRand= rand(@primnum*234.234); is generating your random number based on @primnum, but since you are deleting constraints it will change each time so it will not be stable create prim attrib on constraints before the sim, like: i@primid = @primnum; then in your code use: float myRand= rand(i@primid*234.234); Quote Link to comment Share on other sites More sharing options...
MadMax50 Posted January 13, 2019 Author Share Posted January 13, 2019 @animThank you anim. That makes sense, but unfortunately it still isn't doing what is expected. i have both methods in there using @primid as you said. Maybe you can take a look... appreciate the help nested_rbd2.hipnc Quote Link to comment Share on other sites More sharing options...
anim Posted January 13, 2019 Share Posted January 13, 2019 you are updating positions of your constraints, I get that it's cause you want to detect the P.y, but you can't leave them like that the constraint have to stay at rest, so just use it to create your attributes for deleting, then transfer those to original constraints and delete depending on what you are doing you may be able to use clustering instead of having to alter stuff in DOPs, but I guess this is just a proof of concept for more complex behaviors nested_rbd2_fix.hipnc Quote Link to comment Share on other sites More sharing options...
MadMax50 Posted January 14, 2019 Author Share Posted January 14, 2019 @anim This works great ! I never would have guessed to put an attribute copy to the rest constraints. I have a much better understanding of how the sop solver works now in dops. Thank you !! 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.