Clamp vs random in range blueprints

well i am looking at advanced blueprints 1.1 at content examples and i cant understand the difference between them. 1) They appear to do the same thing at first sight, is there any hidden usage?

Also

  1. we ■■■■ on the variable “number of meshes” even if it has a number for example -100?

  1. what is the last index, i mean it gets the current index the loop has each time…?

  2. since the meshes to spawn array has only 1 entry (SM_lightsculpture) , how it puts cubes too on my play game screen, example below

basically if you can explain the whole random mesh from array thing ( i know what array does and etc, i mean explain the logic)
and lastly here is the whole blueprint if you wanna check things

https://docs.unrealengine.com/latest/images/Resources/ContentExamples/Blueprints_Advanced/1_1/AdvBP_1_1_ConstructionScript.jpg

1) The difference between Clamp and Random Int in Range is that Clamp will take an Integer input and if that integer is outside the Min and Max it’ll set it to whichever is closer.

For example, if you have a Clamp with Min:10, Max:20, and input the value “2”, the clamp will change “2” into “10”. If you input the value “10000”, the Clamp will change the value to “20”. If you input “15” the clamp would do nothing as the value falls between the Min (10) and Max (20).
In the screenshot you posted, clamp simply makes sure the player can’t input a value higher than 1000, or less than 0.

Random Int in Range simply generates a completely random integer between the Min and Max. So if you set Min:1 and Max:5, you would randomly get 1,2,3,4, or 5 as an output value.

2/3) It’s a way to get a random item from an array. If you have an array with 50 items, the Last Index is 49 (0 counts as an index too). If you set the Last Index as the Max value in a Random Int in Range, you will get any random index in that array. You can then use that index number to “Get” the relevant item from the array.

Example:

If we have an array of toys, it might look like this:

  • 0 - Teddy bear
  • 1 - Ball
  • 2 - Doll
  • 3 - Rattle

Last Index gets the final index of the Array it’s attached to. In our example, Last Index would return “3”, as that’s the last item.

By plugging the Last Index into the Max value of Get Random Int in Range, you can get any value between the min and max of the array; in this case, 0,1,2, or 3.

The Get node pulls an item from an array at the given index. So if we input a value of “2” into the Get node, for our example array the output would be “Doll”.

The Get node will use the random number generated by Get Random Int in Range to pull that item from the array. It could be anything between the Min (0), and the Last Index (whatever the final index of the array is).

As for the rest I can’t really help as I haven’t looked at the example project. Hope this helps answer some of your questions.

well thank you man you for answering questions i understood everything. Only thing that remains unanswered is the fact that as it shows in picture n3, it has more than 1 type of mesh, while the array named meshes to spawn has only one index at number 0 the light sculpture mesh. Any thoughts anyone?