How do create a inventory with weight

0 favourites
  • 2 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi in short i want to create a way that a character has a back pack that carrys so much weight, during there travels they pick up items, in the companion app they select items in a list menu that they found and added to there back pack which theb counts up the weight (kinda like fallout and skyrim) how would i do it please and indulged diffrent size back packs with higher weight limits etc

    Thank you for your time !!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can use instances Variables,

    Add an Instance Variable = "Weight" to the Objects to be carried

    And then Add Two instance Variable to the Bags = "MaxWeight" & "CurrentWeight"

    Example:

    Nife = 20

    Cooking Pot = 100

    Helmet = 100

    wardrobe = 50.000

    Lets say that the Bag has already inside (Nife, Cooking Pot, Helmet) so

    CurrentWeight = 220

    BagMaxWeight = 300

    Now say you wanna add another Item, in this case, the wardrobe as an example

    on your Trigger to add the Items to the Bags first check or compare the "BagMaxWeight "

    Bag: compare instance variable = "BagMaxWeight " is greater than

    Bag.CurrentWeight + wardrobe.Weight ?

    -If not you cant ad the object

    -if yes then add the object to the Bag & add the object.Weight to the "Bag.CurrentWeight"

    If you ever want to drop an Object

    Remove the Weight of the object from the Bag

    Bag subtract from "CurrentWeight" >>>>>>>>object.weight

    If I didn't understand your question properly let me know

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)