Day 23. Game Programming Design Patterns

I will go through the design patterns that I learned:

Singleton. It is the pattern that good to use when the functionality will have no clones. It is only one class for the whole program instantiated at the start. You can have global access to it without creating an instance. Very comfortable to use for managers classes like GameManager, UI manager, SpawnManager, and so on.

Object Pooling.

This pattern easy to understand if you imagine recycling cans in the real world. Instead of Instantiate and Destroy objects, you can create a pool of an objects that appear and hide after use. After it is hidden, the called object can appear without instantiating. If you need more active objects at one time, you can dynamically add them to the pool until the threshold is satisfied. Another example is shots that the enemy and player can strike. Must have these patterns on mobile devices game.

Command.

The pattern that you can use when you need to record a player’s actions. Replay it or rewind it.

Observer.

This class is useful when you need to apply action on an already instantiated object. Instance observe for a programmed event that can be appeared on a controller and do the action. Very useful when you have no idea how many instances will be created, but you need to change their state after all, without knowing each copy. Instead of looping through all copies and calling for change, copies will wait for the event from the controller that will trigger programmed inside the instance code.

Flywieght

This pattern is about static variables. It is inviting to make static all variables that will be the same value for all instances of a class. Imagine you have 100000 copies of a cube with a variable named “_speed.” If the speed is the same for those cubes, you can make it static. It will store variables only once for the whole copy pool. It can save some memory.

That’s it with patterns. I am moving forward with the cinematography course.

Sleeping Guard: Cutscene

I learned about the Cinematography module you can install from the package manager. It is adding for you to use Virtual cameras. With a virtual camera, you can compose the shots using a timeline and create cuts. On the timeline, you can put your cameras and overlap them, so it starts smooth moving between each other. It looks like a good Hollywood movie screening for me.

Unity 3D crashes on Apple silicone M1. So, if you run a brand new M1 chip as I do, you can face some difficulties working with Unity. Your project can crash when you load it in Unity Hub. I found a thread with a solution that worked for me.

https://forum.unity.com/threads/unity-on-apple-silicon-and-big-sur-known-issues-and-workarounds.929220/

What you can do is add in Advanced Project Setting this string “-force-metal” It will force to use shader API named Metal.
I am also experiencing disappearing projects in Unity Hub. Simple Hub restart help sometimes. Another time I have to add a Project manually.
I hope it will help someone.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store