Seen a few answers for similar things on the answer hub but couldn’t get any to function for me. How does one add a static mesh component to an actor they have defined (in my case, AItem). It inherits correctly from Actor but I haven’t found a simple way of doing it!
Additionally, I have put several of my classes in folders (or filters as VS calls them) but when adding a new class via the editor, they are removed. Any way to prevent this?
About the disappearing classes, I had this same problem the other day. I ended up finding them in “[GameProject]/Intermediate/ProjectFiles/”. After I found them, I closed Visual Studio and the editor, and moved those files to a spot in my Source folder. Then just to make sure everything was alright again, I launched Visual Studio, removed the files I had to move to the Source folder from my project, and re-added them. Hope I helped! Good luck!
Thanks a lot for the tips! I did foolishly forget to mention, however, that I’d like to add a mesh at runtime dynamically, so I can’t really do so in the constructor. I could cache a lot of meshes and choose from them at runtime, but it seems silly to load dozens and dozens upfront and just store them in memory. Any tips?
Also another poor choice of wording in my original post - my classes never disappear, but whenever I add one, the folder/filter structure I set up in Visual Studio always disappears and my classes end up as one huge disorganised list.
I would assume you would need to set the component up in the constructor and then in a function you would just need to load in the static mesh and populate the component’s static mesh with the loaded in static mesh. This is how I would do it anyway. You will need a component for the mesh to be placed in and I don’t believe you can add a component at run time. I have successfully added components at run time through blueprints but not sure how to do it in C++. How I am going to go about handling items in my game is have the items themselves be in blueprints that extend my base class or sub class if it needs a little extra functionality or components for that item. I can’t remember off the top of my head how to find a static mesh and load that in to the component but I would assume it is similar to loading in a texture which is below.
I would assume it is similar to that of how to do so in UnrealScript which is StaticMesh’Path/To/StaticMesh’ but if someone could clarify that would be great as I will have to figure this out myself for future parts of my game.
I hope this helps you in figuring out what you have to do.
Lol yea but that’s when the best ideas come to me.Unfortunately I forget a lot of the syntax at that point as well so I am always fixing syntax more than actual coding.