Making Components

My apologies if this question has been answered before, but I’m at the point where I’ve done a decent amount of searching around, and all of the answers are either too old to work or aren’t answers (from what I can see). I’ve read through the LY docs on creating components, but thus far I can’t seem to figure it out.

With regards to that: How do I go about making a component? I come from Unity and Unreal, where components seem to be used in the same way (more or less). The problem is, making them in LY seems much more involved. That’s not necessarily bad, but I’m genuinely struggling to figure out how to do it. Most posts I’ve seen have suggested to do it with a Gem. Great. But how?

I can (probably) figure out the code behind the component. What I’m confused about is: Where do I put them? How do I integrate them? Is there a specific place the files must go? Things like this are where I’m getting tripped up.

Thanks for any help you can provide,

Sloan P.

This answered so many questions! Thank you very much. Even just this little bit has gotten me to the point where I can at least begin writing some code instead of banging my head against my desk for hours.

I do have a quick question though. If possible, and again, I apologize that this is somewhat of a beginner question, but would you mind going a little further in depth with the:

  • Any code files you add are in the .waf_files file in the folder with your Gem. You will probably need to configure the gem.json file and might need to change the wscript file which handles dependencies.
  • Once you have a working Component class you just need the matching file paths in the .waf_files and to update the descriptors list in the Module class’s constructor and that should get your Component started.
    bullet points? Is there a reference for this somewhere that would explain how to go about configuring these?

Thanks very much! I’ll keep it in mind!

I’m not aware of any recent online documentation for most of that, which is frequently asked for, but you can probably find examples in other Gems such as “StarterGameGem” or other Lumberyard Gems. I usually just use a text Search option in my Editor to search the Lumberyard code base for specific strings like “->DataElement(” or “->Attribute” or something similar which creates a fairly good summary of what your probably looking for. You can change the .waf_files file names but they all get tied into the wscript file in your gem’s folder.

  • Start “Lumberyard Project Configurator 1.12.0.0” which should be a link on your desktop after installing.
  • Select an existing Project or create a new one and then click the “Set as default” button with the desired project selected.
  • Click the “Enable Gems” link under the Project Name.
  • Click the “Create a new Gem” button, name it, and click the “Create Gem” button.
  • That should create a new folder in the [InstallPath]/dev/Gems folder with the name of your new Gem.
  • Make sure that new Gem has a check next to it in the Gems list and click the “Save” button in the top right corner of the window. After that you should be done with the Project Configurator.
  • Open up a tool that will give you a cmd window and go to the [InstallPath]/dev folder and from there you can run the WAF Commands used to Configure, Clean, Build, etc.
  • Run “lmbr_waf configure” and let it do its thing. This step is typically only needed after changes to the active project such as changing the enabled Gems or the currently active project.
  • Run “lmbr_waf build_win_x64_vs2015_profile -p all” and let it do its thing which will take a while since it is a full compile of the Editor, Engine, and active Project. The other build settings are in the link I previously provided but “lmbr_waf build_win_x64_vs2015_profile -p game” is probably the command I run most often to test Gem compiling.
  • Any code files you add are in the .waf_files file in the folder with your Gem. You will probably need to configure the gem.json file and might need to change the wscript file which handles dependencies.
  • Create any Components you want by creating a class which inherits an AZ::Component class and provide all the necessary functions and fill out the Macro’s with a unique UUID. The Reflect function has a lot of settings in it used to expose your variables in the Editor or for other purposes.
  • Once you have a working Component class you just need the matching file paths in the .waf_files and to update the descriptors list in the Module class’s constructor and that should get your Component started.