UE3 - UDK Noob question: accessing random object from inventory

  • 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.

Dakatsu

Elite Nova Corps Member
Mar 25, 2005
15
0
0
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. :)
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
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.