Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Hide/Show Static Mesh By Name

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

  • Hide/Show Static Mesh By Name

    Im wanting to Show/Hide static mesh elements found on a map by using a function call from a HUD element. Whats the best way (and example code) to do this?

    thanks in advance for any assistance !

  • #2
    myStaticMeshToHide.Destroy();

    Comment


    • #3
      I think I should be more clear... mystaticmeshtohide would be the actor holding the static mesh and to unhide it you would respawn the actor in a way to conserve space. Although just setting a staticmesh property to none inside the staticmeshcomponent should do the trick but I haven't really tried it.

      Comment


      • #4
        1. You need to get the reference to the actor you want to show / hide
        2. Instead of spawning / destroying it, I would set the actor's bHidden Value to false, to hide, and to true to reshow it. As far as I know, Show/hide and Spawn/Destroy may both have the same effect. Although I imagine Spawn/destroy would have more overhead cost, but that's a guess.

        beyondunreal.com/UE3:Actor

        Comment


        • #5
          Thanks guys I'll give it a go :-)

          Comment


          • #6
            How do I get the reference to a static mesh (lets say a wall with browser name of StaticMesh'LT_Buildings2.SM.Mesh.S_LT_Buildings_SM _BunkerWallA_STR') that was placed in the Unreal Editor ?

            Comment


            • #7
              Originally posted by au123
              Thanks for your input but
              How do I get the reference to a static mesh (lets say a wall with browser name of StaticMesh'LT_Buildings2.SM.Mesh.S_LT_Buildings_SM _BunkerWallA_STR') that was placed in the Unreal Editor ?
              The idea is this for a top-down game - where the player can hide/show above levels by pressing a UI button. So if the player is on level 1, pressing the hide/show will unhide the level overlay above.

              To get a reference I know of a couple ways, and likely not all.

              Trace: you trace from somewhere to somewhere else. It will return the first actor it hits. i.e. ActorReferance = Trace(...);
              TraceActors: Like trace, but it will only return a specific type of actor, and skip actors not of the desired class.
              foreach WorldInfo.AllActors(class'desiredClass', ActorRef) : This will iterate through all actors in the level. This is not really ideal as it is the slowest.
              Overlapping Actors:
              Touching Actors: Growing Sphere of detection that returns all instances of desired class.

              *My knee jerk thought for this:
              1. Create a new class extended from static mesh actor. Give it a new var() int; that will basically be what tier of overlay it is.
              When ever you put in a static mesh to your level, do it from this new class, set the overlay tier # on it.
              2. In the postbeginplay() of wherever this exec function to show/hide overlays is, do an
              Code:
              foreach WorldInfo.AllActors(class'NewClassExtendingStaticMesh', ActorRef)
              {
                  If(ActorRef.OverlayValue == 1)
                     OverlayArray1.AddItem(ActorRef);
                  If(ActorRef.OverlayValue == 2)
                     OverlayArray2.AddItem(ActorRef);
              }
              Have this iterator sort the different tiers of static mesh into different dynamic arrays, which should likely be global. One for each overlay tier.
              3. In the show/hide functions, iterate through the correct array(s), setting bhide=true or false, according to your needs.

              *not going to work for skeletal / animated models, would need a separate class and a second set of iterators

              The plan is to do the big slow run only once, and then have arrays containing only the needed information to go through.

              Comment


              • #8
                If this is initiated through a UI button then performance shouldn't really be an issue, you can use the AllActors iterator.

                Code:
                function Test()
                {
                    ToggleStaticMeshActor( StaticMesh'LT_Buildings2.SM.Mesh.S_LT_Buildings_SM _BunkerWallA_STR', !bHidden );
                }
                
                
                function ToggleStaticMeshActor( class<StaticMesh> meshClass, bool bHide )
                {
                    local StaticMeshActor A;
                
                    foreach AllActors( class'StaticMeshActor', A )
                    {
                        if ( A.StaticMeshComponent.StaticMesh == meshClass )
                            A.SetHidden( bHide );
                    }
                }

                You can also tag individual actors, or groups of actors in the editor and search by tag.

                Code:
                function Test()
                {
                    ToggleStaticMeshActorByTag( 'Foo', !bHidden );
                }
                
                
                function ToggleStaticMeshActorByTag( name inTag, bool bHide )
                {
                    local StaticMeshActor A;
                
                    foreach AllActors( class'StaticMeshActor', A )
                    {
                        if ( A.Tag == inTag )
                            A.SetHidden( bHide );
                    }
                }

                If in future performance is a requirement, then search and cache the mesh references at the start of play as Slamm suggested.

                Edit: just want to add that destroying/respawning an actor in order to hide it is a bad idea.

                Comment


                • #9
                  Hey Community,

                  We should give Spoof some kind of award for his endless service to us all with his wonderful code and ideas!

                  Thanks for all the help Spoof!



                  Rama

                  Comment


                  • #10
                    I have created a sample bit of code that hides/shows meshes based on a keystroke. It also enables/disables collision. On my map, the results were quite striking.

                    http://oculusdrifter.blogspot.com/20...isibility.html

                    Comment

                    Working...
                    X