Announcement

Collapse
No announcement yet.

Inventory tutorial and explanation?

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

    Inventory tutorial and explanation?

    Does anyone know of some good pages that explain the inventory system in UDK?
    There seems to be no page about it in the documentation.

    #2
    I'm looking through the code, but I can't quite follow exactly how the inventory system is being handled, especially since the whole thing is handled in native code.

    I tried following a sample to where it was creating the player's default inventory, but all the code did was spawn an actor. I could find nothing that tied it in with the player, but the code just issued a spawn command like if I were spawning a projectile. Do inventory items have to physically exist in the world? I thought they would be abstract; I figured the inventory would be an array or a list that gets consulted.

    Comment


      #3
      Controller spawns an instance of it's InventoryManagerClass. This basically acts as a root for a linked list of Inventory-subclass instances. The InventoryManager handles the re-routing of events to each of the Inventory and also things like weapon-switching, using it, performing double-jumps (a special hook in UT's classes, so Jump Boots can be used in UT3).

      Weapons are a specific subclass of Inventory. They also have a SkeletalMeshComponent which is responsible for the first person weapon, but also specify and separate class as third person attachment, which is just the third person SkeletalMesh that gets attached to the Pawn.


      If you add
      Code:
      [Core.System]
      -Suppress=Inventory
      to your DefaultEngine.ini and let the UDKEngine.ini get rebuilt from that, you will get detailed notifications in your log for everything that happens to your Inventory.

      Comment


        #4
        I added the inventory notifications to the log, and I noticed a few things.
        1) The pawn is considered the instigator for the "given to" functions, not the pickup actor.
        2) Ammo does not incur any messages, suggesting that ammo is counted inside the inventory.
        3) When an item is picked up, first the inventory manager declares that is is adding the item to the inventory, THEN the item declares that it has been given to the pawn. (I don't know the significance of this but it does seem odd.)

        I am left to wonder: where is the ammo counted/stored? How do I have an external actor effect an item in a (player)pawn's inventory, such as perhaps to change a variable, state, or execute a function?

        How do I properly add to a (player)pawn's inventory when the pawn is spawned? I especially wonder how I am going to dynamically adjust the player's inventory to reflect items collected in other levels or that are retained even after the player's death.

        I am also unsure how an actor that does not "physically exist" in the game is capable of handling things like firing projectiles, but I suppose that I don't need to understand since the functionality is already built and present.

        Comment


          #5
          Just because you don't see an Actor doesn't mean it's not there. It may be bHiddenGame, may not have any PrimitiveComponent in it or no Sprite. Actors, by their definition, exist physically in the game world.

          And Ammo is just a variable declared in the Weapon subclass of Inventory. You can just trace through script where that variable is accessed to see how pickups influence it.

          Comment


            #6
            Originally posted by Crusha K. Rool View Post
            Just because you don't see an Actor doesn't mean it's not there. It may be bHiddenGame, may not have any PrimitiveComponent in it or no Sprite. Actors, by their definition, exist physically in the game world.
            Which is why I put "physically exist" in quotes. But see, where is the actor? I suspect that it's not attached to the pawn, it's just floating out in space somewhere. And even if it is attached to the pawn, it isn't being "held" in the pawn's hands. And yet it manages to directly effect the pawn and execute functions that depend upon that pawn's location. It seems odd that this even needs to be an actor, since it is just an arbitrary class anyway. This whole system is completely different from any that I would imagine.
            But that whole matter is irrelevant anyway.

            If ammo is a variable in the weapon, then why can I pick up ammo for weapons I don't have? Where are those variables being stored if there is no weapon tied to my inventory that can store said variable?

            And I still wonder how I can store variables/inventory items that the player is going to retain between levels and after dying. If standard inventory is stored as arbitrary actors that are linked to each other, when the player dies these actors are destroyed, and when a new level is loaded they don't exist. I have my starting inventory because code in the game and/or level tells the game to spawn that inventory. But if I have dynamic additions to that list, then I need to store that data somewhere.

            Comment


              #7
              That "somewhere" is something that depends on your own implementation as coder. UT code doesn't need such functionality, so it's not included.

              And the Actor is at the position in the world that it's Location vector tells it to be. You can log the Location of each Inventory, if you are curious about it. And of course has Inventory enough ways to get informations about it's owner when it needs them.

              Comment

              Working...
              X