Announcement

Collapse
No announcement yet.

need help with Spline Component optimization

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    need help with Spline Component optimization

    Hi all, I have asked this question before, but it did not get very far. In the end I was still left confused, and I think if I give an example snapshot of my blueprint this time, this should help clarify things that I need help in.

    The purpose to what I am trying to accomplish, deals with trying to add an array of static meshes to a spline. For example, the array could hold several different style houses, for which every house that is placed along the spline, I need the Blueprint to randomly choose from a list of houses that I supply in the editor. So in other words, a spline could have 3 different kinds of houses spread out through the entire spline on random choice. Now, someone from a prior thread once did mention to me that I will need a static mesh component for each different static mesh that is in the array. However, between my previous discussion and other threads from others who have asked almost the same thing, the best I could come up with was to add a AddInstancedStaticMeshComponent, connect the return value of it to a SetStaticMesh and connect the editable static mesh in the static mesh node. So from there on, that is what I did. However, I then came to thinking, that this sounds silly, because as the Blueprint is looping through the code, at some point, the random generator is going to pick a static mesh that has been already added to an ISMC. Therefore, this means that I am only making a bunch of ISMC, instead of adding the duplicates to the original ISMC.

    To help clarify this, I have made a snapshot of a stripped down version of my original Blueprint, since the other stuff in the original Blueprint is not related to my question. Overall, I think I am actually doing this wrong, which, I was hoping that someone could help me and take a look at the sample image of my Blueprint below.
    Attached Files

    #2
    Of course you're doing it wrong.

    Add Instanced Static Meshes components manually in the blueprint hierarchy and only use Add Instance in the actual graph.

    Comment


      #3
      You need two loops in your constructor script. First loop iterates on the static meshes array and creates one InstancedStaticMeshComponent for each mesh and store them into another array. The second loop creates the houses and selects a random instanced static mesh component from the array to call addInstance on.

      Comment


        #4
        Originally posted by manoelneto View Post
        You need two loops in your constructor script. First loop iterates on the static meshes array and creates one InstancedStaticMeshComponent for each mesh and store them into another array. The second loop creates the houses and selects a random instanced static mesh component from the array to call addInstance on.
        This sounds promising. However, my first attempt left me with a bunch of empty elements in the second array as the array kept randomly changing in size. I am wondering if I need to setup an add & remove last recursion like in the race track spline mesh component live training?

        Comment


          #5
          You could try clearing the arrays first thing in the constructor script. You can also try making your array properties "transient" (select the propert, expand the "advanced" section in the details), which will cause their values to not be saved along with the actors, so they should always be empty when the constructor script first runs.

          Comment

          Working...
          X