Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Unity Getting Started with Game Foundation Preview

Discussion in 'Game Foundation' started by mingz-unity, Sep 23, 2019.

  1. mingz-unity

    mingz-unity

    Unity Technologies

    Joined:
    Oct 12, 2017
    Posts:
    10
    What is Game Foundation

    Game Foundation provides you with pre-built common game systems (such as inventory, currency, stats) that are flexible and fully extensible, so that developers can focus more on building the unique gameplay instead of reinventing wheels on the most common / essential systems.


    Installing the Preview Package

    Game Foundation Preview is released as a preview package in Package Manager. Minimum required Unity version for the package is 2018.3.

    Please refer to the Installing pre-requisites guide for a step by side guide on how to install it.

    We currently support these Build Target platforms: iOS, Android, Mac, Windows


    Game Foundation Developer Guides

    Game Foundation Concepts
    • Definitions and explanations of various specific terms used in Game Foundation
    QuickStart tutorial
    • Overview of the basic steps to get up and running with Game Foundation
    API Reference
    • Detailed Scripting API reference documentation for Game Foundation
    Editor UI
    • Overview of the various editor user interface to create and manage definitions
    Overview of Game Systems
    • Overview of the inventory, wallet, and stats system currently available in the preview
    Known Issues and Limitations
    • A summary of known issues and limitations in the current release
     
    Last edited: Sep 24, 2019
    Lurking-Ninja likes this.
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    4,624
    Yay! QQ: when the announcement was made it was told that it will be a mobile package. I took a quick look (without downloading, because I can't do that right now) and I haven't found any reference to any hard mobile prerequisite. Does this mean that the GF will be a general purpose package for any kind of application rather than only for mobiles?
    I'll play around with this a bit later.
     
  3. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    Game Foundation is not inherently limited to mobile and should also be fine on desktop platforms. There may be limitations on some features on more-restrictive platforms (WebGL and consoles.)
     
    Lurking-Ninja likes this.
  4. MadanyNO

    MadanyNO

    Joined:
    Apr 18, 2016
    Posts:
    7
    i was wondering if i make a custom Detail Definition, can i require that it will need another Detail on the item? like u do with some components?
    like i make Equipment Definition and i want it to require the stat definition. is there a way to go about that? dont think i saw one in the ducs

    edit: if there is explantion on what needed to be done to add new Detail Definition it could be helpfull too since my new Detail Definition doesnt show up to be add on the Game item details
     
    Last edited: Oct 10, 2019
  5. mingz-unity

    mingz-unity

    Unity Technologies

    Joined:
    Oct 12, 2017
    Posts:
    10
    Thanks for reaching out @MadanyNO. Some very good questions here.

    Custom Detail: it's not entirely impossible to do, but quite difficult since we haven't well documented the API interface for you to create your custom details. We do have plan to better support this option for developers in the near future, including better documentation / explanation that you mentioned, so stay tuned.

    Also in the meanwhile, if you can share with us your use case / what you want to do with the Custom Details, it could also help us take that into consideration when designing it.

    For your question on required Detail: yes that's something we're currently looking into as well. We haven't made final plans yet on how that can be supported, but we do understand it can be useful sometime.
     
  6. MadanyNO

    MadanyNO

    Joined:
    Apr 18, 2016
    Posts:
    7
    tnx for answering me @mingz-unity i really see a lot of potential in GF as some one that tried to self create system like that for myself.

    about what i am trying to do is something like this:

    create a detail definition for Equipment, which would hold the type of it and the rarity of it. at list for now.
    and i want it to require the Stat detail so i can give bonus stats when equipped.

    For example i will create a game item, name it "One Handed Sword" and add the Equipment Detail to it.
    in the detail i will give it the type "One-Handed Weapon" and the rarity of "Common".
    And because i put the stat detail as required, it would add the stat detail or worn me i need to add it myself.

    i kind of expect the code for the Equipment detail i described to be something like this:

    Code (CSharp):
    1. [RequireDetail(typeof(StatDetailDefinition))]
    2. public class EquipmentDetailDefinition : BaseDetailDefinition
    3. {
    4.  
    5.     public EquipmentType type;
    6.     public RarityType rarity;
    7.    
    8.     public override string DisplayName()
    9.     {
    10.         return "Equipment Detail";
    11.     }
    12. }
    to use the RequireDetail just like i use RequireComponent r RequireComponentData.

    Also, i created a class like that(without the RequireDetail) in my project, but when i try to Add the detail, i only see the details that come with the package.
    Is there a need to do something more when creating new Detail? Because i watched the presentation about GF in Youtube from Unity Copenhagen and it seems like a thing i should be able to do.
     
  7. mingz-unity

    mingz-unity

    Unity Technologies

    Joined:
    Oct 12, 2017
    Posts:
    10
    Thanks for the additional information @MadanyNO. The scenario you described makes a lot of sense.

    Indeed it requires more steps than just that to get your Custom Details supported right now, but better support will be provided in the near future so that developers can be relatively easy to add their own Custom Detail.

    One additional follow-up question from the user story you provided above. I noticed you're using 'type' as an attribute in your Custom Detail to model the different types of Equipment. Is there any particular reason you prefer to do it this way, than say using the Definition on the left side (e.g. creating a new definition for each type of equipments, assuming if you can also use Inheritance to link to the base Equipment)?

    We try to provide a flexible system so there's no 'wrong' way to do it, but currently we do see more cases where developers would use Definition for that purpose, while using Detail for holding specific attribute for a concept.
     
  8. MadanyNO

    MadanyNO

    Joined:
    Apr 18, 2016
    Posts:
    7
    not sure i got how you suggested to handle the equipment type...
    did u mean to make a game item of one hand sword, and then when i want to create a new sword i create a new inventory item to inherited detail from my one hand sword, then it simple, i didnt think about that XD
    i did see the why u did the sword item in the tutorial, but i guess it didnt strike me as what i was looking to do

    and the EquipmentType is more of an enum, to use as a label, and in my opinion it is easier to create the equipment like that. Because say i made an sword item with all the stats, info, and now i think that this equipment is more of a lance then a sword so i want to change it to lance, so i only need to change the label, and its a lance, and i wont need to change the inherited from sword to lance.
    so my equipment detail is more of something i would like to have each item to itself and not something he inherited.
    at list that what i was going for.

    i am mainly playing around with GF to test it and see how i feel with it compered to the old made up system i created for myself a year ago as a project for my degree ^^" my system worked but it had lots cons.... i guess i still think on creating items as i created in my system ^^"
    now that i think about that, i can even use the category as a label instead of my equipment type.

    on another note, i was wondering about something:

    can i use the categories i created to sort or get only specif items in my inventory that belong to specific category?
    for example if i have a tab window in my in-game inventory that i want to present only potion that were categorized as "potion" items, can i use the categories to get only the items that categorized as "potion"?
     
  9. erika_d

    erika_d

    Unity Technologies

    Joined:
    Jan 20, 2016
    Posts:
    315
    Hi @MadanyNO,

    Thanks for trying out Game Foundation and sharing with us your use cases!

    As far as your question about looking up groups of items based on their category, yes, that is a thing you can do! It looks like a bug in our documentation that it's not showing up in the scripting reference, but here is a list of method signatures that you can call from Inventories:
    - public InventoryItem[] GetItemsByCategory(string categoryId)
    - public void GetItemsByCategory(string categoryId, List<InventoryItem> items)
    - public InventoryItem[] GetItemsByCategory(int categoryHash)
    - public void GetItemsByCategory(int categoryHash, List<InventoryItem> items)
    - public InventoryItem[] GetItemsByCategory(CategoryDefinition category)
    - public void GetItemsByCategory(CategoryDefinition category, List<InventoryItem> items)

    For the one's that return void, they will add the list of items that fit the category into the List<InventoryItem> that you pass in.

    And just as an added note of clarification, I saw you mentioned further up about creating custom details because you saw it in the presentation from Unite, I just wanted to call out that parts of that presentation was a demonstration of plans we have for the future of Game Foundation, so certain things, like the custom details, aren't supported yet, but we plan to in the future.

    Hope that helps!
     
    mingz-unity likes this.
  10. MadanyNO

    MadanyNO

    Joined:
    Apr 18, 2016
    Posts:
    7
    Hi @erika_d

    Tnx for the list of method!
    and about the custom details tnx for clearing up that it isnt yet supported, i will wait for the update with those.

    tnx for answering my question till now, i will keep playing with Game Foundation to test it and wait for update on custom details for more use cases :)
     
    erika_d likes this.
  11. MUGIK

    MUGIK

    Joined:
    Jul 2, 2015
    Posts:
    151
    Hi
    I just tried Game Foundation and now wondering how can I implement such game with it:
    The game is about managing houses. Each house has its own settings and a list of rooms. Each room also has its own settings and characteristics (simply to say 'Details'). And Room also contains a list of items (such as bed, microwave, table etc)

    So my idea is next:
    Create 2 game items and details:
    1. House (id: house) with HouseDetail
    2. Room (id: room) with RoomDetail
    3. RoomItem (id: roomItem) with RoomItemDetail

    Then in inventory populate items:
    - House_1 (id: house_1, reference def: house)
    - House_2 (id: house_2, reference def: house)
    - House_1_Room_1(id: house_1_Room_1, reference def: room)
    - House_1_Room_2(id: house_1_Room_2, reference def: room)
    - House_1_Room_3(id: house_1_Room_3, reference def: room)
    - House_2_Room_1(id: house_2_Room_1, reference def: room)
    - and so on...
    - Table(id: table, reference def: roomItem)
    - and other room items

    Problems and questions:
    1. it will become a mess if I will have more than 5 houses in the game. Yes, I can use categories, but anyway... Maybe I should make it differently?

    2. Can I create new Houses and Rooms at runtime? So not predefined houses but random one?

    3. How can I link items to room or vice verse? (store items' ids in RoomDetail?)


    It is just an example. In a racing game, there will be garages with cars with some upgrade modules that can be installed.
     
    mingz-unity and erika_d like this.
  12. MadanyNO

    MadanyNO

    Joined:
    Apr 18, 2016
    Posts:
    7

    about your 2nd question sadly creating new items in run time is blocked for now in Game foundation, u still can create a script that will randomly create those rooms but it needs to be done before you enter play mode you can create new items by using InventoryItemDefinition.Create(string id, string displayName).
    if u want u can have an editor window that will randomly create a new room when u press on a button or create 100 random rooms on a different button.

    about the way to go about the game u described, i would probably go about it something like this:

    create all the base items like table and such first.
    then go to inventory and create 2 new inventories:
    1. roomInventory
    2. houseInventory
    make sure they are not auto created

    Then use a script to create a InventoryItemDefintion for a room with a custom Detail for RoomInfo that will hold a room id.
    Then for each room created, create an inventory for the room using InventoryManager.CreatInventory(roomInventory, string name). for the name use the room id from from the room detail. or "room_xx" where xx is the id.
    then add randomize items to the room inventory you created.

    make houses the same way as rooms. and i think that will work for u.

    for now, u can only do this from scripts outside play mode, but it is do able with editor windows and such. and after u created all those rooms and houses u dont need to create them again.

    at list that how i will go about it.

    if u want random every time u start a new game, that will need to create them in game mode which isnt possible right now.
    hoped i helped some what :)


    btw @erika_d is there a reason creating at playmode was blocked? i think it limits a lot of Game Foundation abilities to open option for users to use it.
     
    MUGIK and erika_d like this.
  13. erika_d

    erika_d

    Unity Technologies

    Joined:
    Jan 20, 2016
    Posts:
    315
    Hi @MUGIK,

    Thanks for your question and use case. I think my answer of how to go about setting up something like this ended up being very similar to @MadanyNO's but I'm including it below since I've got some added details about setting it up in the existing editor windows and using stats instead of custom details.

    A few callouts to start out with:
    - At the moment, there isn't an ability to create custom details, although that is intended to be included down the line, as shown in our Unite video. You can create your own stats, which are (currently) numerical (float or int) pieces of data and can be attached to items as a statDetail. So if your characteristics are numerical, you could create them as Stats and attach them that way.
    - Also reference definitions are currently supposed to be a 1:1 mapping between game items and inventory items. There's currently a bug in the UI that allows a game item to get set as a reference definition for multiple inventory items if it's the first time it's being connected, but that's not currently the intended use pattern. This is something we're evaluating though, as we've definitely seen and experienced ourselves the use case for applying one template to multiple items.
    - I also think the easiest solution to your question would be if inventories could also be items to be added to another inventory. That's not currently possible, but something that we have seen use cases for, and have added it to our list of possible things to consider in the future.

    Ok those being said, I think this is how I would go about it:

    - In the Inventory tab of the Inventory Editor Window I would create
    1) A House inventory definition
    2) Room inventory definitions for each type of room you want (i.e. Living Room, Kitchen, Bedroom, etc). For the room inventories I would make the id numerical only (i.e. 1, 2, 3). The numerical only id will be kind of a pain when coding it, so I would add in your code an enum or dictionary that maps the numerical ids to a readable/rememberable id.

    NOTE: For both house and room inventories, you could create just one of each type and leave the default items empty and fill them with items on the fly during runtime, or you could create multiple of each with each configuration of default items that you want in them (i.e. House1 which would have a bedroom and a kitchen, House2 which would have a bedroom, a kitchen, and a living room, and Kitchen1 with stove and table and Kitchen2 with stove, table, microwave, oven)

    - In the Inventory Item tab I would create:
    1) The roomItems that you want to be able to put in the room inventories (i.e. table, light, bed, microwave). You could use categories to identify for each roomItem what rooms they are eligible to be added to, which might be useful for random generation later.
    2) A room inventory item for each room inventory you created. I would then attach to each room inventory item an inventoryId stat detail, and assign the numerical id for the inventory that the inventory item maps to in the stat detail.

    For each of the relevant items you could add additional stat details for any of the settings and characteristics you wanted to associate with them (assuming they can be defined numerically) instead of creating custom details for them at this time.

    This set up allows you to create groupings of rooms within houses, and roomitems within rooms, and different configurations of each grouping.

    In your runtime code then, you could instantiate as many House Inventories as you want from the House InventoryDefinition you set up in the editor. If you created multiple House InventoryDefinitions then they would already have the rooms set up for each, if not, then you could add the rooms to each inventory (Either intentionally or through a randomization algorithm). And same with the rooms. You can instantiate as many copies of a kitchen room inventory and inventory item, adding the kitchen inventoryItem to the house inventory and adding roomItems to the kitchen inventory, if that makes sense.

    @MadanyNO, to answer your question, you are correct that you can't create or edit new definitions at runtime for now (although you can instantiate and edit as many runtime items/inventories as you want). The reason we prevent that is because there were some difficulties with serializing and saving new definitions on the fly and edits to existing ones. We're aware though that having the ability to make changes like that at runtime would be helpful and it's an issue we're conscious of trying to solve.

    Hope that all helps and is clear! Thanks again for both of your input, questions and answers!
     
    MUGIK and mingz-unity like this.