1
$\begingroup$

Animation nodesV2/Blender 2.79

Trying to get a Random Index as a part of a Subprogram.

Attempt 1 - GetRandomListElement not updating in viewport
GetRandomListElement is not updating in the viewport (eventhough the colors change in viewer on update).Tried using ViewportMaterial & SetVertexColor Nodes.

enter image description here

Attempt 2 - IterationCount not connecting to RandomNumber Node
While trying to extract a random index from a Color List for animation ,their doesn't seem to be any node which calculates the total iterations in the list.

On connecting the IterationsCount(Invoke subprogram) to the random number node ,all nodes get red.

How to extract a random index from a list (as a part of a Subprogram)?

enter image description here

$\endgroup$
2
  • $\begingroup$ Are you trying to get a random index or a random color ? (ie : do you want to do something else with the random index than setting a random color ?) $\endgroup$ – Gorgious Apr 12 '20 at 12:06
  • $\begingroup$ Random Index from a List (the above color list is just an example). $\endgroup$ – starzar Apr 12 '20 at 12:12
2
$\begingroup$

I don't think you need to get this kind of convoluted node tree if you just want a random color.

The "Get Random Elements" node has a "Single" mode which will output a single randomly chosen value.

The setup :

enter image description here

Result :

enter image description here

If you just want a random index, you can use the "random" node with a floor math node.

enter image description here

$\endgroup$
5
  • $\begingroup$ Thanks for the answer,but this setup needs to be part of a Subprogram.Any way to implement it would be really helpful. $\endgroup$ – starzar Apr 12 '20 at 13:44
  • $\begingroup$ Alright, could you elaborate on the specific task you are trying to accomplish ? $\endgroup$ – Gorgious Apr 12 '20 at 15:08
  • $\begingroup$ Chaining animations -Subprograms provide the ability to chain other animation loops....so using lists with subprograms is always a better option. $\endgroup$ – starzar Apr 12 '20 at 16:57
  • $\begingroup$ Sorry but I really don't understand what you are trying to do in your subprogram ? In your question you are creating an exact copy of the base color list, is it the intended behaviour ? $\endgroup$ – Gorgious Apr 12 '20 at 17:02
  • $\begingroup$ Subprograms allow easy linking of more than one Iterator/Parameter/Generator as compared to creating separate logic nodes groups and combining them together. $\endgroup$ – starzar Apr 13 '20 at 3:52
0
$\begingroup$

Index values can be accessed by using the GetListElement Node ,which gets elements according to their indices and then connecting this to the "Max" Random Number node to create an index range from which random indices could be instanced.

random index from list

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.