Kosmos School: Live Science Classes in VR
This guest post was written by Can Olcer, co-founder of Kosmos School.
Kosmos School offers live science classes in VR for teenagers. For example, they perform physics experiments to learn about gravity or engineer a rocket which they can then board and fly away with. All learning happens collaboratively (multiplayer, if you will).
The classes focus not only on hard skills (like math and physics), but also super important soft skills like critical thinking, creativity and collaboration. Students don’t sit in a virtual classroom. Instead, every class takes place in different fantastic environments like islands, forests or foreign planets and students work on relevant problems, acquiring skills that they will help them have a head start in their careers and life.
Learning collaboratively is key
In primary and secondary education, the social factor is extremely important. More and more, we won’t be teaching kids how to write beautifully by hand or learn something by heart, but they will be learning how to work together in teams, how to approach problems, and how to think critically. Those are the skills needed in this century. And these skills can only be learned when working together with others. That’s why multiplayer is fundamental to the success of Kosmos School.
Students work on science experiments together
Photon’s different services helped us get everything we needed to work within a couple of weeks (we’re a small team of two developers and one 3D artist). Currently, we’re using PUN (as we use Unity), Photon Realtime (instead of rolling our own server), and Photon Voice (it’s crucial that the students and the teacher can all talk to each other).
One key game mechanic is that any player can spawn an item from their inventory with which every other player can interact. Our Fuel Lab is a great instance of that. By using it, students can make different products by a chemical process known as fractional distillation. For example, they can create kerosene that they can use later to fuel their rocket.
Per default, interacting with a Gameobject is not networked. Other players don’t see what a player locally does with it. Luckily, Photon offers an easy way to change that: Remote Procedure Calls (RPCs).
RPCs for the win
Technically, RPCs are regular methods that are decorated with [PunRPC]. This decoration makes the method a method of that Gameobject’s PhotonView component and when that RPC is called by e.g. photonView.RPC(“RPCMethodName”, Rpc.Target.All), that method and everything in it is synchronized over the network to all players.
Here’s an actual code example showing how we handle it when a player turns on or off the Bunsen burner.
// LabTempButton.cs
// this method is called when the player interacts with the Bunsen burner
// this is part of a script that handles the Bunsen burners' button logic
public override void HandlePressAction() {
if (type == Type.TempUp) {
tempPhotonView.RPC("TempUp", RpcTarget.AllBuffered);
}
if (type == Type.TempDown) {
tempPhotonView.RPC("TempDown", RpcTarget.AllBuffered);
}
if (type == Type.GasKnob) {
tempPhotonView.RPC("HandleGas", RpcTarget.AllBuffered);
}
}
// LabTempControllers.cs
// this method is decorated with [PunRPC] and therefore can be called by
// the above method as shown
// this is part of a different script that handles the main logic
// of the Bunsen burner
[PunRPC]
public void TempUp () {
// bunsenOn = true;
changeTemp = !changeTemp;
increaseTemp = true;
decreaseTemp = false;
}
If we would have called the method without RPC, then only the player who interacted with it would see effects locally. Should we use a Switch statement instead of the three If statements? Probably. But that’s not the point here.
Looking forward
What’s in store for Kosmos School in the next couple of months? We have a lot planned. We want to move away from temporary rooms to persistent ones. So that you can build stuff, log out, and come back in later to continue working on it. And we want to make Kosmos School an MMO experience. A place where you can learn new stuff and make new friends.
As mentioned, currently we’re using the Photon Realtime as our backend. Photon Realtime is a hosted server by Photon. The advantages of that are that it’s much simpler and quicker to get started (we don’t need to build our own backend). The disadvantages are that Photon Realtime has some limitations. It’s designed for room-based games and the server is not authoritative. So, you can’t use it to make an MMO and one player (called the Master Client) is always the authority on syncing everything to all other players. A downside of that is for example that cheating is easier.
While we can get room persistency to work with Photon Realtime (using another great Photon service called Photon Webhooks), to realize our MMO plans we will need to switch out Photon Realtime for our own backend built with Photon Server. Photon Server gives you much more control over how you want to handle game mechanics on the server side while not forcing you to start writing our own server software from scratch. Win-win!