Game Structure
Unity's Structure
First, a little bit about how the Unity game engine works.
In Unity, everything in the scene is a GameObject
.
These GameObjects have a bunch of Components
that give it a specific behaviour, like movement, collisions, attacking, etc.
A Component
is essentially a C# class.
A class is basically a collection of data (member variables
), and functions (member methods
) that acts on and modifies that data.
So for example, in the basic example, you saw the gravityScale
member variable of the Rigidbody2D
Component being used.
In the Unity Editor UI, here's what it would look like to set the value of the gravityScale
member variable
on the RigidBody2D
Component attached to the Player
GameObject.
For member methods
, an example of something you might call (in C#) on this RigidBody2D
Component might be:
playerRigidbody.AddForce(new Vector2(69, 420))
Also, GameObjects
can be nested under each other as children, so for example there might be a Right Leg
child GameObject under the root Player
GameObject:
Which means the GameObject named Right Leg
will have its position, rotation, and size be based on the Player
GameObject.
That's pretty much it for the fundamentals of how Unity works.
Meme Game Structure
OK, so that's Unity. But how about Ye Olde Meme Game 2? Well, YOMG2 basically adds a thin layer on top of Unity. And that layer is MemeItems
.
In your level that you build, you add a bunch of MemeItems
to it, e.g. Memeorang Man
, Ohio
, John Xina
, or Stonks
.
Whenever you create a ModScript
, it must be added to a MemeItem
that's in your level.
Each MemeItem
in your level consists of a root GameObject, and sometimes some child GameObjects.
And that's kinda it. Just so you know, behind the scenes, each MemeItem has a MemeItem
Component that I made, as well as some other specific Components that causes the MemeItem to behave like it does, but you'll figure all that out by playing around with modding and reading these docs.
The glue between Unity and MemeItems
The way the modding system glues Unity
and MemeItems
together is as follows:
From your ModScript, you retrieve some MemeItem
in the level, then access some parent or child GameObject
on that MemeItem
, then access any Component
on that GameObject
.
Now you can interact with any member variable
or method
on that Component
.
Now with that said, let's take a look at the API Reference, which should help you visualize all this better.