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, 2020 at 12:06
  • $\begingroup$ Random Index from a List (the above color list is just an example). $\endgroup$
    – srt111
    Apr 12, 2020 at 12:12

2 Answers 2

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$
    – srt111
    Apr 12, 2020 at 13:44
  • $\begingroup$ Alright, could you elaborate on the specific task you are trying to accomplish ? $\endgroup$
    – Gorgious
    Apr 12, 2020 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$
    – srt111
    Apr 12, 2020 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, 2020 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$
    – srt111
    Apr 13, 2020 at 3:52
1
$\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$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .