Game Dev Notes #2 – Snowboarder

These are notes from the Complete C# Unity Game Developer 2D Udemy Course

Profiles

Unity comes with lots of existing packages that contain default profiles. We can override them by going to assets -> create -> 2D -> Sprite Shape Profile. Then we can click and drag onto the Profile section in the inspector. That will let us use the sprite profile we created instead.

When we create a new sprite profile, we can click on it and drag an actual sprite to the Sprites section of the profile.

Cinemachine

Install Cinemachine from the Unity package manager. It will auto-add it to the main camera.

Click on the virtual camera it created and change “Body” to “Framing Transposer”. Then choose what to “Follow”

Sprites

You can create an “empty” parent object and click and drag sprites underneath it. Children’s position is then relative to their parent.

Collision

We can add a Surface Effector (2D) to our floor which will create a “conveyor belt” movement. We need to make sure it is attached to the edge collider by selecting “Used by Effector.”

For our main object that is interacting with the surface, we want to change the rigid body Collision Detection to “Continuous”

“Rigid Bodies” are the things that physics are acted against in unity.

Scene Managing

We can import `UnityEngine.SceneManagement` to manage scene stuff.

Particles

Two parts:

  • emitter: the object that emits particles
  • particles: the actual particles

Game Dev Notes #1 – Race Car

These are notes from the Complete C# Unity Game Developer 2D Udemy Course

Debug

Debug.Log( "Message" );
Debug message to console.

Collision

Add components:

  • [Shape] Collider (2D)
    • Play with the shape depending on what kind of collision feel you want.
  • Rigid Body
    • Turn gravity to 0 if this is not a platformer
    • Add rigid bodies to other objects if you want them to be pushed.

Scripts:

OnCollisionEnter2D
When colliding with something.

OnTriggerEnter2D
When passing through an trigger object.

Referencing Other Objects

There are a few ways to reference other objects inside scripts.

[SerializeFiled] GameObject <name>
This will create a field in the object’s inspector that you can manually select from the list. This then stores that object in the variable name you set the GameObject to.