These are notes from the Complete C# Unity Game Developer 2D Udemy Course
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.
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”
- Dead Zone Width/Height: Choose how much the player has to move before the camera will start to adjust
- X/Y Dampening: How aggressive the camera is following the player
- Lens Ortho Size: How closely the camera is to the followed object
Add a polygon collider to your background tilemap and set it to the borders of your world.
Then go to the cinemachine camera object and go to Extensions and choose Cinemachine Confiner. Drag background tilemap to Bounding Shape 2D.
But now you have to be conscious of layer collissions. Players and background as the same layer, so we need to separate them. So create separate layers for player and background and assign them.
Then under Edit > Project Settings > Physics 2D, use the matrix grid to uncheck everything for Background, so it doesn’t physically collide with anything.
Right Click > Cinemachine -> State Driven Camera
Drag any other follow cameras underneath the state driven camera.
Set the Animator Target to the player animator (or the animator of whatever you’re trying to follow), then use the + icon to add a new state that’s set in the animator you created.
You can use the “Solo” button to see which camera you want when previewing.
You can create an “empty” parent object and click and drag sprites underneath it. Children’s position is then relative to their parent.
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.
We can import `UnityEngine.SceneManagement` to manage scene stuff.
- emitter: the object that emits particles
- particles: the actual particles