Help: Allocating a Transform from a switch on INT

Hi

I am spawning up to 5 x 3D widgets. I have set locations preset. I would rather not have 5 spawn nodes per choice if I do not need to.

What would be the best way to do this?

So if 1 has stock, only the top line will fire, or if stock 1 & 3, then 1 & 3 get spawned.

Hello,
Instead of switch, use an array and “get” your BaseRef to “set” “DestRef”. Then use the “DestRef” for your “spawnActor”

Hi

I may of missed a bit in the description.

When I said I have set positions, I should of said that the widget could be spawned in any of the 5 locations depending on how many others are spawned.

So if only No 5 has stock, then it will spawn in position 1, but if No 3 and No 5 have stock, then No 3 would spawn in position 1 and No 5 would spawn in position 2.

I think I may of bitten off more than I can chew.

This is what I attempted, but FAIL

Set an array with each transform set at the index of your “NumberOfStock” value (variable “DestRef is useless in fact” except if you use it later) :

Edit : I may have misunderstood (once again) do you want to spawn one actor or the ones when stock is not = 0 ?)

Hi

Spawn when they have stock so player can purchase it.

I think I accidentally worked it out. Does this look like it would work, it looks to be firing correctly. Messy I know.

Capture.JPG

One concern is how I am putting the REF at the beginning of the SETs.

Here is my idea : You set your different stocks (which was not obvious at start as you shown one only) in an array, loop it and when different to 0 you spawn with transform array :

Edit : Don’t forget to reset currentLoc on completed !

Edit 2 Another idea is to use your “number of stock” value as start value for currentLoc or as value to spawn if you don’t want do the array. But with array you no more need to set this variable.

So does that mean that the Preset Location, will spawn because of the Current Loc number, will look through array and get lets say the 3rd one down.

So I could use this for the name and price amounts, when I cast them to the widget?

I didn’t try with umg. But in level, if arrays are arranged in the same way, you’ll have the same result and will can spawn each correct element at the right place, but in the same loop body line, or you’ll have to do one check for each type of spawn. (you can do a function too, but you’ll have to add eventual transform modification as input)

Tried this, no spawning or I have no idea where they did :slight_smile:

And I got this error:

Warning Can’t parse default value ‘0’ for Produce Name Array . Property: Produce Name Array.

Warning Can’t parse default value ‘0’ for Produce Price Array . Property: Produce Price Array.

Just did a try with a blueprint with a widget in, it works. Check the scene outliner, to see where they are in your level and then check your transform ( rotation scale).

Edit : I modified my widget bp to modify widget easily by adding a box as root.

Ok, in the Game five are there, They are spawned no where near where the use to and on top of each other, I am a little confused.

Capture.JPG

Before, they were spawning in front of this building.

Capture.JPG

This is how my convoluted way works.

Capture.JPG

This is how I set the furthest ones out.

I do have an error somewhere.

3 Spawn where they are suppose to, 2 spawn over where it spawned before when I was trying your way.

I will need to do some investigating to find out what on earth has gone wrong.

Thank you for you help again.

Regards

Worked out, 2 are spawning at 0/0/0. That is where they were spawning when I tried you way.

I can not see why only 2 would be doing that.

Looks like a headache heading my way.

Regards

Sorted

Had wrong transformes pluged in.

Your great suggestion:

602cb440be20b735ea9c6bf9eb94e174ceb15850.jpeg

I did this:

Capture.JPG

And it could be done like this:

Capture.JPG

WORKED :).

Thank you for your help, me learning new pretty things the .

I am happy that helped you ^^

Edit : to set text values in widget blueprint in same loop. Index is used for values :