I create the match with bot and i add bot to the match in cloud code like this:
var matchId = Spark.getData().matchId; var matchData = Spark.getMultiplayer().loadMatch(matchId); var participants = matchData.getParticipants(); if(participants.length == 1){ matchData.addPlayersById("5a0add2795b16304fd4fc89d"); participants = matchData.getParticipants(); }
But i don't see second participant (my bot) in matchMaking response. How i can add bot to match that i see my second participant (bot) ?
Thanks in advance.
Vitaly
Hi Vitaly,
You could add the bot to your match and return the match participants in the UserMatchFoundMessage with the following:
var matchId = Spark.getData().matchId;
var matchData = Spark.getMultiplayer().loadMatch(matchId);
var participantsData = matchData.getParticipants();
if(participantsData.length == 1)
{
matchData.addPlayersById("Your Bots PlayerId");
participantsData = matchData.getParticipants();
}
//Set and Get the matchData with the following
matchData.setMatchData({"participants":participantsData});
matchData.getMatchData(participantsData);
Does this solution look like it would work for you?
Thanks,
Ronan
At the point in which the MatchMaking Response runs, the response has already been formulated. You can append to it, but you can't directly change it.
Adding a bot to the match in the response will successfully add them to the match, but it won't be seen in the response.
You can add extra scriptData to be returned with the response, indicating that you've added a bot player for instance.
-Pádraig
Do you mean something similar like this?
Hi Ronan.
Yes, thank you for your help.Vitaly
Vitaly Evtukh
I create the match with bot and i add bot to the match in cloud code like this:
But i don't see second participant (my bot) in matchMaking response. How i can add bot to match that i see my second participant (bot) ?
Thanks in advance.
Vitaly
Hi Vitaly,
You could add the bot to your match and return the match participants in the UserMatchFoundMessage with the following:
var matchId = Spark.getData().matchId;
var matchData = Spark.getMultiplayer().loadMatch(matchId);
var participantsData = matchData.getParticipants();
if(participantsData.length == 1)
{
matchData.addPlayersById("Your Bots PlayerId");
participantsData = matchData.getParticipants();
}
//Set and Get the matchData with the following
matchData.setMatchData({"participants":participantsData});
matchData.getMatchData(participantsData);
Does this solution look like it would work for you?
Thanks,
Ronan
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Vitaly,
At the point in which the MatchMaking Response runs, the response has already been formulated. You can append to it, but you can't directly change it.
Adding a bot to the match in the response will successfully add them to the match, but it won't be seen in the response.
You can add extra scriptData to be returned with the response, indicating that you've added a bot player for instance.
-Pádraig
Vitaly Evtukh
Do you mean something similar like this?
Thanks in advance.
Vitaly
Customer Support
Hi Vitaly,
You could add the bot to your match and return the match participants in the UserMatchFoundMessage with the following:
var matchId = Spark.getData().matchId;
var matchData = Spark.getMultiplayer().loadMatch(matchId);
var participantsData = matchData.getParticipants();
if(participantsData.length == 1)
{
matchData.addPlayersById("Your Bots PlayerId");
participantsData = matchData.getParticipants();
}
//Set and Get the matchData with the following
matchData.setMatchData({"participants":participantsData});
matchData.getMatchData(participantsData);
Does this solution look like it would work for you?
Thanks,
Ronan
Vitaly Evtukh
Hi Ronan.
Yes, thank you for your help.
Vitaly
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics