question

brendan avatar image
brendan asked

How to handle multiple character per player?

Galla.adam
started a topic on Mon, 30 March 2015 at 3:14 AM

I'm wondering if there is a way to handle more characters per player account?

Here is an example scenerio:

An RPG game where the player can create more than one character, and every character has its own separated inventory.

Is it possible in the current system, or should I build my own solution to achive this?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Best Answer
Brendan Vanous said on Mon, 30 March 2015 at 2:31 PM

Actually, we recently introduced a Character system, to specifically address this need:

https://api.playfab.com/Documentation/Client/method/GrantCharacterToUser

https://api.playfab.com/Documentation/Server/method/GrantItemsToCharacter

https://api.playfab.com/Documentation/Server/method/MoveItemToCharacterFromCharacter

https://api.playfab.com/Documentation/Client/method/UpdateCharacterData

https://api.playfab.com/Documentation/Client/method/GetCharacterData

https://api.playfab.com/Documentation/Server/method/GetAllUsersCharacters

https://api.playfab.com/Documentation/Server/method/UpdateCharacterStatistics

etc.

There's also a GetCharacterInventory API, which will be on our live site later this week. Let us know if there's any additional functionality you'd need for this.

Brendan


7 Comments
Galla.adam said on Mon, 30 March 2015 at 3:33 AM

I already figured out a workaround. But maybe there is better solution.

here is my idea:
I would use two type of player:

  • BasePlayer for the player acount
  • CharacterPlayer for the characters.

The base player will have a variable in the PlayerData that stores all the character names he has.

When the player log into the game he will do it as normaly with username and password.
When the player selects a character on the character selection screen, the system will log in with that character using the character name as username and the previous password.

Is it possible to log in with two accounts from the same client, or should I disconnect one before logging with the other? (I'll try it as soon as possible, but right now it's a theoriticaly question)


Brendan Vanous said on Mon, 30 March 2015 at 2:31 PM

Actually, we recently introduced a Character system, to specifically address this need:

https://api.playfab.com/Documentation/Client/method/GrantCharacterToUser

https://api.playfab.com/Documentation/Server/method/GrantItemsToCharacter

https://api.playfab.com/Documentation/Server/method/MoveItemToCharacterFromCharacter

https://api.playfab.com/Documentation/Client/method/UpdateCharacterData

https://api.playfab.com/Documentation/Client/method/GetCharacterData

https://api.playfab.com/Documentation/Server/method/GetAllUsersCharacters

https://api.playfab.com/Documentation/Server/method/UpdateCharacterStatistics

etc.

There's also a GetCharacterInventory API, which will be on our live site later this week. Let us know if there's any additional functionality you'd need for this.

Brendan


Galla.adam said on Tue, 31 March 2015 at 12:20 AM

Yeah I found this Character system in the documentation yesterday, but I didn't found yet in the unity sdk. Should it be in the PlayFabClientAPI class?

Another problem that I had, I don't really know how this character system works. I was confused by the documentation, could you explain what is the logic behind this system?

The documentation says:
"Grants a character to the user of the type specified by the item ID. The user must already have an instance of this item in their inventory in order to allow character creation. This item can come from a purchase or grant, which must be done before calling to create the character. "

I have an idea how it's working, but need a confirmation. So here is an example:

  1. I create a catalog with a name of characters for example, this will contains all the playable characters in my game.
  2. I create two new character: Legolas the elven archer and Bilbo the halfling burglar.
  3. Now I add Legolas to my players inventory, becouse he is the basic character that is playable.
  4. When a player want to play with legolas I "GrantCharacterToUser", so he will have an instance of Legolas.
  5. Let's say Bilbo is not a free character, so the player can buy it. When he buys it, Bilbo will be added to the players inventory, and we can use point 4 again.

Thats fine, but what if I don't have predefined characters? I would like to let the player choose his race and class, so he can make an elven burglar or a halfling archer? How would I design this in this character system?

Refering to the character inventory api: thats awesome. :) Will it visible in the game manager too? That would be nice. :)


Galla.adam said on Tue, 31 March 2015 at 2:26 AM

Also the following methods would be nice to add (sorry if they are already implemented, didn't find them):

Remove Item From Character

Or is it achivable with MoveItemToCharacterFromCharacter if I set the reciever to null?

Delete Character

The opposite of GrandCharacterToUser


Brendan Vanous said on Tue, 31 March 2015 at 9:33 AM

There actually is a DeleteCharacterFromUser. Were you thinking of a version of this function callable from the Client?

For removing items, there are two ways to do this:

"Durable" items (non-consumables) aren't meant to be removed from the player entirely, apart from as an administrative action.


Galla.adam said on Wed, 01 April 2015 at 1:14 AM

No, server side character delete is fine and logical.

Hmm I'm not sure how to use the admin operations. I would like to remove the item from a character for example in these cases:

  • The player sells his sword at a vendor.
  • The player simply drops his sword out of his inventory

How could I implement something like that I mentioned above? where the player character builds up from a race and a class combination?
I'm basicly planning my MMORPG-like game. However I don't want massive server side logic. Your system looks perfect for it.

Should I just make 1 character as an item, and add at character creation I can set up the parameters... if that make sense. But I still didn't find the 'GrantCharacterToUser' method in the sdk, could you tell me where to search it?


Brendan Vanous said on Thu, 02 April 2015 at 10:53 AM

Right now, the system is designed for "durable" objects, which cannot be removed from the player inventory, and "consumable" objects, which have a use count or timeout value. If you want to have objects which can be removed, right now you would need to make those consumable objects.

As to characters with race and class (or any other properties), that's entirely up to you as the developer. The items needed to create characters are simply to make sure players can't create characters in ways you don't want them to. You could just use one item type for character creation, and just vary the specifics of the character the player owns based upon the properties you set, using UpdateCharacterData.

GrantCharacterToUser is in the Client SDK - the link is above. It adds the Character to the user if the user has the appropriate item in his inventory (and decrements the count of uses for that item, if it has one).

Brendan

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.