Build an Infinite Runner Game with Unity and the Realm Unity SDK

Hi Everyone,

You may or may not be aware, but we have a Realm SDK for Unity in the works! To give everyone a taste, I’ve cooked up a tutorial that makes use of it:

The tutorial is for building an infinite runner type game. Think Temple Run or Subway Surfer where you kind of run forever dodging obstacles and collecting rewards.

The SDK is currently alpha so expect that there could be bugs. As the SDK progresses and improves, I’ll be sharing more content on how to build amazing games that persist to Realm and MongoDB!

Please don’t hesitate to reach out if you have any questions.



Hi there,

I’ve been following this tutorial.
Can somebody please explain to me why the method PlayerStats() is being declared twice in this script?


public class PlayerStats : RealmObject
    public string Username { get; set; }

    public RealmInteger<int> Score { get; set; }

    public PlayerStats() { }

    public PlayerStats(string username, int score)
        this.Username = username;
        this.Score = score;


Hi @Manuel_Tausch,

Are you referring to the constructor method and the overloaded constructor method? Since it is a class, we need to be able to set the variables. We use the overloaded version throughout the project, but Realm has a requirement that we have a basic constructor as well.

Does that help?

Hi Nic,

Thanks for your reply!
I guess I haven’t seen this syntax before, especially since I’m new to C#, coming from the Python side of things.
So you class definition is PlayerStats, then your basic constructor is “public PlayerStats() { }” and the overloaded version is “public PlayerStats(string username, int score)”?
Do you have a link by any chance where I can read up about this in detail?
I’m definitely curious as to why you need to declare this constructor twice or is that just some quirk that I need to accept and not wonder too much about it?


Hey @Manuel_Tausch,

This link might help for method and constructor overloading:

If you can accomplish what you want using the default constructor, then you don’t need to create others. However, you can create as many variations as you want, as long as you have the default, even if you don’t plan to use the default.


1 Like

Awesome, thanks a lot! I will review that 100%!!!


1 Like