Announcement

Collapse
No announcement yet.

Spawning actors during level load

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

    #16
    Why not just use a construction script on an actor to do this? Or a blutility?

    Comment


      #17
      Originally posted by GalaxyMan2015 View Post
      I have an overridden EditorEngine class (You can set the EditorEngine override class in the Engine.ini) where I implement any code that needs to be loaded with the editor in the Init function. This happens around the 86% mark when loading the editor, I can't tell you if the assets are gatherable at this point, I rely on all external data at this point.

      Then I implement the same code (Obviously more streamlined for game execution) in the GameInstance::StartGameInstance function when executing standalone. At this point a default World has been created, in which I am able to dynamically spawn all my assets into and then setup the default game mode and spawn the player, so by the time it has left StartGameInstance, I have my world ready to play.
      Tricky! I'm writing a plugin for distribution so ini files might not be an option. For now I've managed to trigger stuff when the plugin window is fired and it seems to show by default. The user has to access the plugin window to enable the job it's doing each time anyway, so that solves it for me.

      I'll keep that in mind though, it sounds useful. I'm wondering if I'll have to override the viewport class in the same way and then figure out a way to write to the ini file. I don't see anything stopping me from doing that then forcing a reload.

      Comment


        #18
        Originally posted by ZoltanJr View Post
        Why not just use a construction script on an actor to do this? Or a blutility?
        Unfortunately I'm not using blueprints, I didn't check what subforum we were in before replying.

        That does raise a possibility though. Is there any way to include in a plugin a blueprint with a constructor that will fire even if it's not in the world?

        Comment


          #19
          It might be a possibility with an OBJECT rather than an ACTOR and the new blutility panel thats in 4.9, but I haven't really tried that yet. I normally have blutilities on actors that I have in the level, but definitely worth a shot

          Comment


            #20
            If you don't know how to do it, just say so. Everyone second guessing the guy, and not listening. And here we are, another frustrated user, wanting the same thing. Luckly OP had made another post, where he finally got an answer.
            To all the Nay-Sayers and the WhyDontYouDoItThisWayInsteaders:
            https://forums.unrealengine.com/deve...179#post228179
            Now this thread can be closed finally. And I can finally go to bed.

            Marc Audy
            Unreal Engine Developer
            In terms of injecting your actors when the level is loaded I think you'll want to look at attaching delegates to FEditorDelegates::OnMapOpened and FCoreDelegates::PostLoadMap. The editor one is called when the map is opened, the core one when a map is loaded for gameplay. You'll probably need to be careful to avoid duplication in the Play in Editor case.

            There is also a FEditorDelegates::PreSaveWorld which may be relevant to your needs for updating the state of the actors when the map goes to be saved. As I mentioned previously I think to avoid the Actors being saved out you'll want to flag them transient when you spawn them. Another alternative would be to allow them to get saved, but strip them out/update them in the OnMapOpened to pick up updates. The nice thing about this approach is it means that when you cook your final level you'll have the actors in place as I imagine you don't want to be referencing the DB to place these actors in a final build.
            Free Community Ocean & Sky Project || Join us on Discord! || Trello Roadmap
            Plugins:
            ComputeShader CPU->GPU->CPU || UniversalTimePlugin || UniversalSkyPlugin

            Comment


              #21
              Originally posted by EvoPulseGaming View Post
              If you don't know how to do it, just say so. Everyone second guessing the guy, and not listening. And here we are, another frustrated user, wanting the same thing. Luckly OP had made another post, where he finally got an answer.
              To all the Nay-Sayers and the WhyDontYouDoItThisWayInsteaders:
              https://forums.unrealengine.com/deve...179#post228179
              Now this thread can be closed finally. And I can finally go to bed.

              Marc Audy
              Unreal Engine Developer
              This post is from 4 years ago... This can definitely be done in blueprint quite easily and show with several items on the marketplace which now exists.

              Comment


                #22
                ^ This. The original posts were made four years ago, during which time capabilities for blueprint scripting have changed dramatically.

                Four years ago, what FlippedBit wanted to do wasn't possible through blueprint scripting, so he created a new thread in the programming section where he resolved his problem.


                Originally posted by EvoPulseGaming View Post
                Now this thread can be closed finally. And I can finally go to bed.

                Comment


                  #23
                  Thats fine, here is the OP's answer (ignoring the fact that its in the blueprint section, and focusing on the question itself)

                  Well I took matter into my own hands shortly after my last post and created my own "inject actor on map load" plugin system

                  https://github.com/UE4-OceanProject/TimePluginDev
                  https://github.com/UE4-OceanProject/SkyPluginDev

                  These are singleton-like actors that are auto injected into any level that you load in the editor, new or saved map (during editor loading or game play loading).
                  To get exactly what the OP asked for would require small modifications, but hooking the map load was what the OP was looking for. (without using gameplay events)

                  These two plugins come with a blueprint library that exposes the singleton-like actors with the nodes:
                  Get Time
                  Get Sky
                  From there you can call their own functions / get variables ect

                  Free Community Ocean & Sky Project || Join us on Discord! || Trello Roadmap
                  Plugins:
                  ComputeShader CPU->GPU->CPU || UniversalTimePlugin || UniversalSkyPlugin

                  Comment

                  Working...
                  X