In my blueprint I got a public variable ‘selectionGroupComponents’ with type ‘Static Mesh Component’ (Array).
But when I attach it to a blueprint I still cannot assign values to this variable:
Why is this list empty and doesn’t show static mesh components of this blueprint? It seems that blueprint script components cannot access components of their parents, so it’s not possible to assign values to their variables.
Hey ,
I wasn’t able to reproduce this in a new 4.7.5 project. To test, I created a new Actor Blueprint and gave it a New Blueprint Script Component of type Scene Component. In new Scene Component BP, I added a Static Mesh Array variable. After compiling/saving both Scene Component BP and parent Actor BP, I was able to add an array element in parent BP and assign element a Static Mesh through drop down menu.
Are you following a different process? Are there any steps I missed in attempting to reproduce bug? Are you able to reproduce in a new project?
Hi ,
thanks for investigating. That’s pretty much my workflow, with one exception:
type of array isn’t ‘static Mesh’ is it ‘static mesh component’. I need to assign components of parent blueprint to blueprint script component.
In this case, I need to give the ‘isSelectable’ blueprint script component references to other wheels (static mesh components) so it can manipulate them.
Hey ,
Thanks for extra details. It turns out I was looking in wrong place entirely; it appears that Static Mesh Component variable defaults can’t be set in Details panel at all, regardless of whether it’s a Scene Component BP. I’ve entered a bug report for this (UE-14076), and I’ll let you know when I see an update on it.
For now, you can get around this by setting Static Mesh Component variable in Construction Script. This can work with Scene Component BP variables as well, as long as you reference component first and then Set its variable. Let me know if you have any trouble setting that up.
Hope that helps, and thanks for report!
Hi ,
your workaround does job for now. Thank god for copy & paste.
Hi there,
any news regarding this bug for 4.8? It’s very complicated to work around this issue for me.
Thank you,
Hmm, guess that means ‘no’.
Nope, it just means that we were out on vacation Monday =)
I took a look at bug, and it’s been closed as “Not a Bug”. I spoke with developer about it, and here’s what he said:
"You can’t bind component and variable like that. SMC (Static Mesh Component) variable is just a pointer to something else, and doesn’t actually get bound to any data that you can modify.
"Making an array of static mesh components can’t actually create components. What he’s seeing is an array of read only components. He’d have to populate those with components added in construction script in order to manipulate them.
"When you add a component via component tree, there’s an automatically created component variable for you to access, which is set to component that’s spawned in there. So, that variable has an actual component associated with it, so you can edit it.
“Just creating a new SMC variable doesn’t actually put anything in it. You can reference something else, but for purposes of Details panel, it’s just a read-only pointer. If you want to override, you have to create it in component dropdown.”
To which I responded: “Okay, so if I add a component via component tree, it creates a variable for it automatically. That much makes sense to me. So if I create a variable with Variable button and give it a type “Static Mesh Component”, I can’t actually use it to reference an existing component because one already exists. Making an array out of this is basically impossible, then, unless we set it in Construction Script? What’s point of being able to create a Static Mesh Component variable, then? For that express purpose?”
To which he responded: "There are two common use cases for it:
"1. You want to store off some reference to a component. Say you wanted to have a monster that had a bunch of meshes attached to it. When one gets shot, you want monster to track which one got damaged last, so it could shake it around in pain. You could reference a component that way.
“2. Construction Scripts. Like you said, if you wanted to create components in CS, and then save them off for use later in event graph or elsewhere, you’d store them in a SMC variable or array, and then you’d have access to them later.”
So, long story short, setting values of an SMC array variable in Construction Script is actually correct way to handle this. I hope that helps!
Hi ,
many thanks for your detailed answer. But I am really somewhat confused now. I actually don’t need the content of variable, I also don’t want to write something into it at design-time, but I just want to reference name of it at design time, exactly like you described in (1).
I want to configure individual ‘car designs’ here. It basically just saves information like “load static mesh 1 in component X, then static mesh 2 in component Y etc. and you’re done” (applied in-game).
So it’s just an assignment of meshes to component variables, just like you would adress a IMG-element in a browser and change actual picture at runtime. Of course, this does only works, if game is running but I should be able to configure target components at design time.
But list in class default doesn’t show the names or reference of static mesh component variables either. It’s same for a non-array variable.
That leads to (absurd) and really error-prone workarounds:
As there is no 'get component by name* node either, I have to manually add a tag to each static mesh component which saves it name, so I can later get it with ‘get components by tag’ and select first hit. For being able to configure car design in class defaults I then assign static meshes to tags instead of just directly referencing target component variable (which isn’t listed).
Many thanks for investigating this, really appriciate that. But what’s sense of a pointer or reference if I can’t use it…?
Hi there!
It would require some discussion as a potential new feature if and/or how we should populate list for Component reference variables in Details view - currently Component reference variables cannot be assigned at design time (as you have discovered here). So technically, current bug would actually be that we are exposing those reference variables for editing in Details view for Component defaults in Blueprint Class editor (because we don’t currently have a facility for assigning them at design time - i.e. they are not “assets” per se).
Note that if you create Component reference variables for an Actor-based Blueprint Class, those do not appear in Details view for editing class defaults in Blueprint editor. I believe that is actually current intended behavior.
Also note that we do currently handle Actor reference variables as a special case - in Blueprint editor you cannot explicitly edit them, however in Level Editor’s Details view you are able to assign those variables at design time for a particular instance of Actor-based Blueprint Class to any Actor instance in current level. Unfortunately we also currently expose Component reference variables in that context as well, for which drop-downs will also be empty. Whether or not they should be exposed there for per-instance editing would also require some discussion as a potential new feature request - for example, UI for that might be a bit tricky.
In 4.8 you’ll need to continue to assign those references through Construction Script (as that is only currently-supported method). In meantime we can consider adding an ability to perhaps be able to “predetermine” those values somehow at design time (through tagging or otherwise) so that when Blueprint Class is instantiated those assignments could be set up automatically. I’ve added a new issue for tracking that as a request (reference UEBP-57).
Thanks for feedback/report!
Hmm, thanks for all details. So it seems, there will be no simple solution to reference component variables as targets for later operations at design time. In this case, I’ve to find another solution or workaround.
Thanks anyway.