A little confused. You’re picking up the hit under to cursor and the doing a line trace from that point to 0,0,0. I think you only need the cursor hit.
I think apart from that, the only other problem you have is that trying to figure out which particular piece of foliage you’ve touched is always going to run like a dog with a wooden leg.
How much instanced stuff do you have in your level? Is it fields full of flowers and grass, or just a few static meshes?
"A little confused. You’re picking up the hit under to cursor and the doing a line trace from that point to 0,0,0. I think you only need the cursor hit."
Yes that’s true, i wanted to rework this part of the BP (without knowing how exactly), but i was waiting for fix the more important part first.
"I think apart from that, the only other problem you have is that trying to figure out which particular piece of foliage you’ve touched is always going to run like a dog with a wooden leg.",
I’m sorry, but i didn’t understand what do you mean ? English is not my native language, and i don’t understand the meaning of “always going to run like a dog with a wooden leg” ?
"How much instanced stuff do you have in your level? Is it fields full of flowers and grass, or just a few static meshes?"
I have near 100 00 trees…and yesterday near 1h after my message before i go to sleep, i’ve tested the same bp with a little map, and i think my real problem is the foliage performance…
I don’t have many experience in the foliage perf optimisation, but i use 4 LOD, and with all the foliage i go from 120 fps (without) to +/- 50 fps in average.
Hi, imagine a dog with a wooden leg running, slow right? That’s what I was saying
And I was right, I guess. It will never run quickly because the BP has to loop through all of the instances looking for the one the cursor is touching.
If you want this kind of functionality, you need to do it another way. Some way that gives the player the same idea or feeling, they are clicking a tree and something special happens, but do it without using all the instances.
One way I can think of is to keep all your foliage, but randomly place special trees that will react when clicked and the player has to find them. They look slight different to the instanced ones, but only slightly.
So clicking on the foliage will have no effect, but clicking the special trees will… just an idea…
The problem is that i want to make all the trees usable, i’m making a game where all trees can be cut down and used to construct buildings.
I will try to find a solution first and make some research to optimize my foliage (don’t know if i can do better than now or not).
And if i don’t find solutions, i will make it a different way. Like replace all actual Tree Foliage on my map by BP with a third BP…don’t know how at all, but it’s just an idea. ^^’’
I will try this when i got more time, and will post here after !
Hi, why don’t you convert them only to an actor when you actually want to interact with them? I used a system with thousands of trees where you can shoot the trees and once a tree gets hit, it will be replaced by an actor, when the tree actor gets enough damage it falls down and the tree actors only have a specific lifetime (so when they’re not getting damage inside this time the tree actor will again be added to the instanced static mesh component)
So it seems to me you don’t need to convert at tick, but only when you want to interact with the tree (cut it down) you would replace it with an actor, so only event driven.
And if you go for multiplayer you mind wanna keep in mind that in progress join will be a pain with instanced static meshes.
Yeah, foliage is quite heavy, you should make sure you use an imposter as last lod. If you used assets from the marketplace, then I’m quite sure that they already use imposters as last lod, but if not:
And if you want to optimize your trees, then keep in mind that shader complexity does not show up correctly on the trees, cause since 4.23 masked materials always show green, although they’re not.
Btw the index is per instanced static mesh component, not per all instanced static meshes and everything with one mesh type will be one instanced static mesh component, so flowers with mesh “A” would be one, grass with mesh “B” would be another one and of course the trees with mesh “C” would be a separate one, too.
My advice is that instead of using many static Maya for objects with little relevance on the stage it is better that you use 3d textures since they consume less rendering resources. Usually I use 3d textures for trees and stuff.
Really thank you a lot @chrudimer & @yeisondiazromero for your help, i not home actually and i can’t use my computer, but i take your advice into account your precious advices and i will post here when i will have some news.