Hi there, I am trying to figur out how to put a static mesh component into a variable. I am using a line trace component to pick one of the cylinder components in my BP.
Any suggestions on how to do that? (see attached img).
- David
Hi there, I am trying to figur out how to put a static mesh component into a variable. I am using a line trace component to pick one of the cylinder components in my BP.
Any suggestions on how to do that? (see attached img).
If you have a bunch of already referenced components:
Or look them up:
Or create an array of the desired type and keep adding elements dynamically:
Probably something close to:
Providing I got the intent right! Other than that, do clarify what’s going on.
I am sorry for the confusion “Everyone”, it was a variable solution an not a array I was looking for (updated my question).
Is the line trace component the right node in order to be able to pick one of my cylinder static mesh component, and if so what should I be plugin into the target og this node?
Probably not. Line trace component is used when you already know what you need, it’s an efficient way to trace against something very specific, rather than to select something from a bunch of elements. Try:
Could you clarify what is really needed here:
Selected Cylinder
If so, no arrays are needed. Unless you’re doing something truly unique and must step through very specific components of this actor only.
I did do a test with the line trace by channel, but could not make i work with static mesh components, but it works fine with scene actors (and putting them into a variable).
How ever I found a workaround. Discovered that if i tick the “consume input” on my mouse input, then I can have instances of the same BP in the level responding to the same indput.
Unsure if this is the right way to go …
I am trying to learn BP and is slowly moving forward.
It’s not. Input belongs in the Player Controller
/ Pawn
and should not be enabled for actors, not under regular circumstances at least. For example:
Allows you select any Static Mesh Component
in the scene and reference it in the PC every actor has access to via a cast (if at all needed).
If you’re ever going to have 1 actor with 2 cylinders only, and nothing else, then you could handle the input in the actor, I guess.
Hard to advise without knowing what you’re up to! Your script looks as if you were trying to select-click a component, move it around while a LMB is held and then let go. Essentially, click and drag. I might be wrong, ofc.
Thank you for your example. It is not clear to me what goes in to the “target” of the hit result, when having multiple static mesh component in the same BP? But i might learn one day. I´m an 3D artist learning my way around UE.
You right i am building a simple game where the goal is to move around a number cylinders to avoid getting hit by a ball bounching around a room of walls.
I too am not sure what you mean by this. As mentioned previously, ideally this script should be in the Player Controller:
You could run it in the Pawn, though, and plug in a controller. You could even run it in the Level Blueprint if the game has 1 level only. But the script definitely does not belong in the actor that owns the cylinders. Think about it, the script would be repeated as many times as there are actors… Input consumption aside, it’s a waste of resources and a debugging & maintenance nightmare.
Doing it once is definitely easier to maintain and more logical. Consider it.
I´m an 3D artist learning my way around UE […] am building a simple game
One way another, you will need to learn the about the framework:
Let’s say we want to simplify it greatly and don’t want to even bother with the PC, you could have this in the level blueprint:
The Enhanced Input for this:
In a scenario where I’ve placed 5 actors with 2 cylinders each, we could move any of them:
Is this what you want to achieve? Roughly?
Thank you Everynone
In you example the cylinders is not part (components) of the level BP, right?
I was trying to have it all in one BP to make it easy to build new levels and just drag in two BP (the ball and the “move cylinder”), and then use the level BP when building each level.
Once again thank you for some great examples. I will have to dive in to some of the nodes/setup to learn.
No, the LB cannot have components. Each actor has 2 cylinders - I followed your example. Each cylinder pair is an actor. You place actors in the level. That’s the way things are usually built.
But it does not matter much for this. You can drag any component, no matter what it’s a part of or how it ended up there.
Of course, no component in the LP. I am using an actor BP for the cylinder where I also added the move controls.
Than you for your help. I might bump into more challenges down the road
And this is the exact thing I’ve been harping on and one should absolutely avoid.
Good luck!