i have a blueprint which has 24 instance static mesh components in it. (its a terrain where each instance static mesh is a different terrain tile)
A can get the instance number of each ISM but as each ISM numbers its instances seperatly i need to identify WHICH of the ISM components i want to remove. Is there a way to get the instance static mesh component from the line trace? I know there is a “hit component” however that returns an incompatible name.
i.e. rather than “oceanplain” it returns “BP_MapTerrain_2.OceanPlain Plain”
You should be able to very efficiently identify what’s needed and that’s with 0 iteration. This way the naming convention are not an issue. You can build the map dynamically at the beginning of the game.
Hi, hit component will be the instanced static mesh component that has been hit (if it has hit an ISM) and hit index will be the index of the ISM inside that instanced static mesh component.
So you would cast the hit component to instanced static mesh component (if that fails then you haven’t hit an ISM with that linetrace) and then do remove instance with the hit index.
i.e. rather than “oceanplain” it
returns “BP_MapTerrain_2.OceanPlain
Plain”
I don’t know the naming conventions UE uses in game, but AFAIK the name is a unique identification for the object, so they can’t all have the name “oceanplain”
Didnt work EXACTLY like that what i did was set the component tags as numbers then converted the name to a string then to an int. that way no need for the look up just fed it straight into a select and it worked. thanks for the help. greatly appreciated.
No, they don’t. That’s simply not how things work. You need to cast to get the right type in case you want to do something that the class defines. Casting is super useful for other things but you do not need it to use the Hit Item.
the system will 100% for a fact break
down if I do it without the cast.
No, it won’t. Try it, knock yourself out. If you’re casting for this, you’re just using a very slow and a very inefficient filter. There are better ways.
For instance my level gen using hisms
but if I remove the cast it does
nothing, plug the cast in? Boom
generated level.
Then you’re doing something weird elsewhere. Casting is just a conversion… it does not really do anything magically on its own.
To clarify:
If you get something outside of instance index range, absolutely nothing will happen (have a look at what the BP exposed node does under the hood)
You’re using casting as a filter. Which is OK since the class is loaded but it is unnecessary and slow. There are better ways of filtering things. Tis all. You do not need to cast to use Hit Item instance index is all I’m saying.
…Okay, why don’t you make two separate bps that spawn some hisms, make one trace on the other and then try to delete an instance without the cast? (bp hits hism on other bp, deleting the hit one.)
If I do it the engine assumes I’m talking about an ism component and just does nothing since the trace is infact hitting an hism.
If I do the cast it works fine.
And this is a problem I’ve been having with ue4 for years, until some dude on reddit pointed me in the right direction and I haven’t had problems since, is is entirely possible this is a newer change or maybe situations can have different things occur?
I see what you are saying but what is the “other way” of doing this then? If not a cast How would I get a hit result? The only thing I could think would be to compare some arbitrary data like it’s tag, mesh or sum.
My main point is that for a solution of “hit won’t pick up hism” is to just chuck a cast at it.