Announcement

Collapse
No announcement yet.

Generic guidance request regarding Unreal coding

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

    Generic guidance request regarding Unreal coding

    Greetings.

    I have a background in game development (mostly graphics) in c++ for PC. As somebody who was exposed primarily to big engines written from scratch, I have a hard time adapting to some of Unreal's concepts.

    I will explain in detail.

    When I just started with Unreal, the first question I asked myself was: "where is the entry point?". I found it a bit weird that Unreal does not have a concept of "Load-time" and "Entry" for your code base. There is no place to start setting up things in a classical way, i.e., setting singletons, initializing managers, deserialize data, load data and so on. Therefore, I created one of the automatic construction classes (I believe it was AWorldSettings) that was constructed rather early, and used its constructor as "main" for my code. After that, I registered callbacks for asset load/unload for intrinsic Unreal deserializer to reflect on all assets that were loaded.

    As a next step, I started writing an Item system. First thing that immediately caused confusion - there seems to be no generic Mesh class. You either work with AStaticMesh or ASkeletalMesh.

    Example:
    I want to have the following system in place:

    - On load time:
    ---- create new instance of MyItem myObject;
    ---- Deserialize data file, ie "sword.dat", write all contents in myObject, save Item as archetype in a storage container with some tag, ie "sword".
    ---- Make the object container visible in Unreal editor (the same way the meshes are visible in a folder, for example, so that you could drag them directly in the world)
    ---- Once dropped, the item model will be visible. It can be either an animated model, or a static model. All the public variables should be visible as well.
    -------- When the Drag n' drop is performed, the object archetype is cloned, and a new game object instance is created and saved in the game object container. Archetypes are "const", and the cloned object is "non-const".

    I would prefer to have as minimal exposure to blueprints as possible for core logic (storage, conditionals, data read/write, behaviors) and only leave them for designers to tweak things (like health 100 ->150).

    I understand that what I'm asking may seem a little vague, but please, bear with me
    Last edited by kudovickij; 09-05-2015, 01:45 PM.

    #2
    It sounds like your previous engine experience had a certain workflow that doesn't really exist in UE4. There are a lot of places that you can hook into as an entry point, it just depends on whether you expect the level to be loaded, the world to be initialized, actors to be created and/or game mode ready for play. You could start at the AActor level with BeginPlay and start walking up the call chain to the ULevel that initializes all the actors and from there to the UWorld that initializes the level, from there to either the GameInstance or hop over to AGameMode HandleMatchHasStarted.

    Overall it seems your goal is to be able to define data somewhere externally, create actors using these data sets, drag the actors into levels and let designers make minor tweaks to them. You can do exactly this in UE4, but you need to adjust thinking a bit:
    • Define CSV for each actor variation, this can include pointers to meshes, particles, sound, constants
    • Create a new blueprint BP_X that inherits from base C++ class X
    • Select the desired row of CSV data in BP_X to populate the defaults for the blueprint (meshes, particles, sounds, constants)


    When you're done, you might have BP_X1, BP_X2 ... BP_XY

    Then
    • Drag blueprints into scene
    • Allow designers to tweak any variables that have UPROPERTY(EditAnywhere)


    If on the other hand you're trying to save previous object state and deserialize that state as a new set of defaults for spawning other objects, you're going to have to dip into the save system and deserialize those values over the top of a freshly spawned actor.
    Dev Blog http://www.error454.com

    Comment


      #3
      Dear hyperdr1ve,

      Thank you for your answer. I was thinking about creating blueprints procedurally. I am a bit confused about the general workflow in Unreal for editor. If I want to put 5 units on the map, does it mean that I have to drag the same blueprint 5 times? (this is the impression I got, please correct me if I'm wrong).

      And another question regarding generic data exposure. Blueprint interface allows you to have drop-down menus. I was only able to find an unreal Enum support for drop down lists. Is it possible to populate the drop down list from an arbitrary container?

      Thanks!

      Comment


        #4
        Originally posted by kudovickij View Post
        Dear hyperdr1ve,
        Thank you for your answer. I was thinking about creating blueprints procedurally. I am a bit confused about the general workflow in Unreal for editor. If I want to put 5 units on the map, does it mean that I have to drag the same blueprint 5 times? (this is the impression I got, please correct me if I'm wrong).
        Well of course there are always multiple ways to get something done. For the level designer, they'd probably drag a blueprint into the level and then drag additional copies out as needed. As a shortcut, you can hold alt + left click the transform widget of the object in your level and drag to create a duplicate. For the programmer, you could spawn multiple copies in the level BeginPlay or you could have a single spawner blueprint that you drag into the level that could create X copies on BeginPlay or on some time interval.

        Either way, you can think of this as instantiating unique copies of a class. Once the blueprint is in the level, you can adjust any exposed parameters.

        Originally posted by kudovickij View Post
        And another question regarding generic data exposure. Blueprint interface allows you to have drop-down menus. I was only able to find an unreal Enum support for drop down lists. Is it possible to populate the drop down list from an arbitrary container?
        Thanks!
        Hmm, drop downs. I guess the question is, what are you trying to select between? If you need to select from a list of other classes or blueprints, you can use TSubClassOf:
        Code:
        UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
        TArray<TSubclassOf<ABaseDamageableSpawner>> Spawners;
        Generically, you could also use structs.

        Code:
        USTRUCT(Blueprintable)
        struct FMenuNavigationStructure
        {
            GENERATED_USTRUCT_BODY()
            
            UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Navigation")
            FName MenuItem;
        
        
            UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stuff")
            float Stuff;
        
        };
        I think once you start playing around you'll quickly get the hang of things.
        Dev Blog http://www.error454.com

        Comment


          #5
          Thank you for your answers. This is very helpful info.

          Comment

          Working...
          X