{"id":10506,"date":"2024-07-18T20:22:06","date_gmt":"2024-07-18T18:22:06","guid":{"rendered":"https:\/\/store.algosyntax.com\/?post_type=asx-lms-tutorial-cpt&#038;p=10506"},"modified":"2026-03-09T22:10:33","modified_gmt":"2026-03-09T20:10:33","slug":"ue5-runtime-dynamic-objects-and-fsoftobjectpath","status":"publish","type":"asx-lms-tutorial-cpt","link":"https:\/\/store.algosyntax.com\/tutorials\/unreal-engine\/ue5-runtime-dynamic-objects-and-fsoftobjectpath\/","title":{"rendered":"UE5 Runtime Dynamic Objects And FSoftObjectPath"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"10506\" class=\"elementor elementor-10506\" data-elementor-post-type=\"asx-lms-tutorial-cpt\">\n\t\t\t\t<div class=\"elementor-element elementor-element-ce010ef e-flex e-con-boxed e-con e-parent\" data-id=\"ce010ef\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-cd01c72 elementor-widget elementor-widget-text-editor\" data-id=\"cd01c72\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>A Quick tip on FSoftObjectPath in Unreal Engine: Sometimes you may need FSoftObjectPaths for &#8220;Assets&#8221; created at runtime and thus only available in memory and not on disk. I placed &#8220;Asset&#8221; in quotes cause &#8220;Asset&#8221; is usually used to refer to a UObject that is also serialized to disk.\u00a0<br \/>Anyway, FSoftObjectPath has a constructor that takes in a UObject. So just do this:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-518cf0a elementor-widget elementor-widget-code-highlight\" data-id=\"518cf0a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-cpp line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-cpp\">\n\t\t\t\t\t<xmp>UObject* MyObject=NewObject<UObject>();\r\n\r\nFSoftObjectPath MyObjectPath(MyObject);\r\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-af6b731 elementor-widget elementor-widget-text-editor\" data-id=\"af6b731\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>NB: Things to keep in mind:<br \/><br \/>If you&#8217;re going to pass your FSoftObjectPath to something, just know that its simply a WeakPointer, so you need to hold &#8220;MyObject&#8221; as a UProperty() so that it persists throughout the usage lifetime of MyObjectPath.\u00a0<br \/>Just something to think about it, if GC collects the Object, the ObjectPath is still pointing to deleted objects&#8230;.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"featured_media":0,"template":"","asx-lms-tutorial-categories":[45,86,58],"asx-lms-tutorial-tags":[46],"class_list":["post-10506","asx-lms-tutorial-cpt","type-asx-lms-tutorial-cpt","status-publish","hentry","asx-lms-tutorial-categories-unreal-engine","asx-lms-tutorial-categories-unreal-api","asx-lms-tutorial-categories-unreal-c-api","asx-lms-tutorial-tags-cpp","entry"],"acf":[],"_links":{"self":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt\/10506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt"}],"about":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/types\/asx-lms-tutorial-cpt"}],"version-history":[{"count":0,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt\/10506\/revisions"}],"wp:attachment":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/media?parent=10506"}],"wp:term":[{"taxonomy":"asx-lms-tutorial-categories","embeddable":true,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-categories?post=10506"},{"taxonomy":"asx-lms-tutorial-tags","embeddable":true,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-tags?post=10506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}