I’ve been trying to set a BP cycling through an array of actors with tags, so it only shows one actor at a time but I’ve been struggling at the minute getting the logic right.
I used a multigate/flipflop but as you can see I need to press the F key twice to make the changes:
Also, the plan is to add a simple animation (Int 1 scales down, Int 2 scales up) and also adding a widget as an option with two arrows to go forward and backward.
Any help for pointing me in the right direction is greatly appreciated!
If you want to make them grow and shrink, then it’s much easier to make each one an instance of a blueprint, because you’ll be using a timeline, and managing multiple objects from one piece of code is not worth trying
Thank you! I really appreciate your time and explaining in such detail simplifying the process.
My idea is to be a drag and drop blueprint, add options via struct, so I can swap as many items as desired, and I can assign a tag for items, so for example I’ve got Item 1 (eg. box) which will start the game as visible, then when player press F, it’ll hide and show the next item in the list (sphere) and also cycle through a widget window (using buttons) if desired. Its application is for archviz.
So my thinking is, each index in the Struct will be connected to the element index of the mesh or actor to cycle through the whole array. So the index 0 or first option in the struct will be all actors with index 0.
Maybe you can explain what you want purely in archvis terms?
For example, to stand in the kitchen, and run through all the different hobs available. Or would you want to change all items in the kitchen on each key press, in a sort of ‘these all go together’ kind of way?
For sure! Let’s say I’ve got 3 armchairs that I want to present the client, I place them in the living room and the first option is the one that fits best so it’s visible, but I want the client to be able to swap them pressing a key or with a button via widget.
I’ve done it before where I set the static meshes and also done it via tags and it worked like a charm but I’ve been always limited by the number of available interactions in the BP, so if I needed to present 10 armchairs, I’ll need to create a new BP that allows me to swap 10 static meshes.
What I’m trying to achieve with this BP is to present as many options as I need be either 2,3,4,5,10 and use it throughout the level, whether is a hob, a sofa, an entire bathroom, and each option is differentiated by a tag.
Yes, so it’s a blueprint that can take an arbitrary list of meshes and move to the next one on command.
You would have one copy of it for a chair ( loaded with chair meshes ), another copy for lights ( loaded with light meshes ).
At the moment you’ve placed everything in the scene, which is confusing during the setup, and inefficient during runtime. Not very inefficient, but not a great way of doing it.
Shall I show you how to set this up? You only need one blueprint, all others are just copies of it, loaded with a certain list of meshes.
Ok. So the basic blueprint holds everything, except the meshes. It has an array, ready for the static meshes, and an index variable. By default, the first mesh is a cone, so we can see what we’re doing
So you can see the collision box ( orange lines ), and the default cone, because we haven’t set anything yet. So I’m going to do a chair, I set the meshes
For interaction, you need a way of knowing which object you are near. I hate this method, but we will just get it working for now. Better ways of interacting, and widgets can come later
You can make a widget appear over the object ( as part of the default blueprint ), that’s called a widget component. Or you can make a widget appear on the screen when you get near the object.
Also, long term, a line trace for interaction is better. This method has problems when the objects are very close.
Man you’re truly a hero! It makes sense to me and I did use a similar method in the past but couldn’t figure out how to add more meshes and make them swap.
Just got one more question, is it possible for me to use this method and a struct with an array of meshes?
What I mean is, each index has an array of meshes, in archviz terms would be, the armchair 1 has a footstool and reading cushion, option 2 would be another armchair with a side table and a blanket, option 3 a bean bag only, option n a bookcase and so on.
It’s just to have more flexibility.
Totally, the line trace for interaction is waay better, I set it on my character with an interface and has been much much better than doing it via overlapping boxes.
I would avoid using structs. You will probably end up with messy code, and if you nest things in structs ( like arrays of structs or structs with arrays in ), things also can get buggy.
What you could do, is have more than one array by default. So, the one we have now, and the ‘extra’ array. If there is a footstool with chair 2, then index 2 also has a mesh in the second array.
You would then need a third array to specify the relative offset of the secondary mesh.
An easier option is just pre-merge some mesh combinations you like. Then they just become another mesh.
I loved that I was able to do a forward and backward interaction just by swapping the increment by a decrement, so now I can set the buttons in the widget: