1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

UE3 - UDK Noob question: accessing random object from inventory

Discussion in 'Programming' started by Dakatsu, Apr 19, 2010.

  1. Dakatsu

    Dakatsu Elite Nova Corps Member

    Mar 25, 2005
    Likes Received:
    For the weapon system I want to create each gun will use an inventory object called magazines, which stores information, specifically the ammo in it. A magazine will be interacted with by the weapon, where the FireAmmunition function would reduce the amount of ammo in the Magazine object. Reloading would of course place in the magazine with the largest ammo count.

    What I have no idea what to do is having the inventory/weapon select a Magazine actor if they are all exactly the same (all have the same ammo). It doesn't matter which one, but I don't exactly know how to tell the game this. :)
  2. Wormbo

    Wormbo Administrator Staff Member

    Jun 4, 2001
    Likes Received:
    Does it matter which magazine is loaded when they all have the same amount of ammo? I guess not, so just start out with known ammo count zero and while iterating over the inventory list, remember a magazine (and its ammo count) if it has more ammo than the best already known ammo count. When done, use the magazine you last remembered - no other magazine will have a higher ammo count as that would have been remembered instead.

Share This Page