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

Placing custom actor subclass in level editor

  • Filter
  • Time
  • Show
Clear All
new posts

  • Placing custom actor subclass in level editor

    Pretty basic question here, I'm trying to figure out how I can create a subclass of a StaticMeshActor and then place them in the editor.

    So far I've followed this tutorial: and now I want to extend it a little bit. My goal is to have a static mesh placed in the level that the player can interact with a little more than the standard ones. I want to be able to mouse over it and see a name I give it, like that tutorial does.

    Here's the class I created:
    class MyStaticMeshActor extends StaticMeshActor;
    var() string MeshName;    // I want to be able to get this name from my static meshes
    Then in the editor, I can place a MyStaticMeshActor instead of the standard StaticMeshActor, and give it a name. Like for instance, instead of just having a rock, I now have a rock that I can mouse over and get the name "I'm A Rock" to print to the screen.

    My questions are:
    1) Is this even close to the right way to do this? Is there a different class I should be extending?
    2) How do I get the editor to recognize my new kind of actor so I can place it in the level?

  • #2
    I'd use a property that's already there, like Object >> Tag, which you can easily convert from a name to a string.


    • #3
      Thanks, but the name string thing is just for starters, I'll eventually add a lot more functionality to the class, I should have said that in the OP.


      • #4
        Originally posted by Hunter9000 View Post
        2) How do I get the editor to recognize my new kind of actor so I can place it in the level?
        Seems to be the right way about it to me.

        To get the editor to let you add it create an ActorFactoryStaticMesh subclass, like:

        class ActorFactoryMyStaticMesh extends ActorFactoryStaticMesh;
           MenuName="Add MyStaticMeshActor"
        This adds the desired context menu options to the editor.


        • #5
          Awesome, I figured it would be something simple. However, when I added that class to my package and recompiled, I'm seeing two copies of "Add StaticMesh" in the context menu, and neither of them let me set my MeshName property in the mesh's properties. I tried to find some documentation for ActorFactoryStaticMesh, but there doesn't seem to be a lot out there on how to use it properly.


          • #6
            Make sure your opening brace for the default properties section is on a new line.


            • #7
              Hahaha, either you're psychic, or I made a really common noob mistake. That fixed it! My little prototype is working now, thanks so much to both of you. Only thing that's not working is the name of my factory in the Add Actor menu.

              Under Add Actor, I still see two options for "Add StaticMesh", the first one is my custom version that works, and the second is the vanilla static mesh one. Here's a screencap:

              However, under the Add Recent menu, it has it's correct name, MyStaticMeshActor. See this screencap:

              I've looked through the source code for the Actor Factory classes, and I don't see any vars other than MenuName that look like they could fix this. Is this something I'll have to just deal with?


              • #8
                Maybe I am beeing the noob here but shouldnt you have used the placeable keyword like

                class MyStaticMeshActor extends StaticMeshActor placeable;
                var() string MeshName;
                have u tried that?


                • #9
                  His class inherits the placeable keyword from StaticMeshActor. The point of the ActorFactory is to place it with a static mesh selected in the content browser.

                  I can't explain why the menu text is wrong - works fine on my end. Perhaps the editor cached the name from when you had the default properties wrong, in which case it may be fixed if you load the editor without you mod (remove it from the edit packages in the UTEngine.ini) and then load it with your mod again.


                  • #10
                    I tried that, and it doesn't look like it worked. I commented out my package in DefaultEngine.ini, deleted UTEngine.ini, and did a full recompile. (The full recompile didn't delete my package's .u file, so I deleted it myself, that might not have been necessary) Then I started the editor, and it just had the default factory listed. I added my package back and recompiled again, but it still has the same problem.

                    It's not a big deal, it functions properly, so I'll live with it for now and hope that it's just a bug in the editor, I am using a version of UDK listed as beta after all Thanks again.