21. Unity - 2D game development subtotal 04 --- 2D camera follow movement, sprite material replacement particle effects, ray casting, audio special effects playback, audio spatial sense effect

1. Camera follow (Cinemachine plug-in) and field of view boundary settings

In a 2D game, if you want the camera to follow the movement of the player character in the scene, the easiest way to implement it is to use a plug-in – Cinemachine to set it up: first open the Package Manager
resource management window in the menu bar , then select Unity Registry , in Search, download and install in the search bar on the right, as shown in the figure below: After the installation is complete, click the right mouse button in the blank area of ​​the node hierarchy window and choose to create a simple 2D camera, as shown in the figure below: After the creation is complete, select this For the virtual camera , there is a Follow property in the property window on the far right . Drag and drop the player character node followed by the camera here to realize the real-time follow function of the camera. As shown in the figure below: Set the boundary area: When the player character moves to the scene boundary, the following camera will shine around the player character, and the area outside the scene will also be displayed, and the phenomenon of crossing the boundary will occur. At this time, you need to give Set a bounding area following the camera
insert image description here

insert image description here

insert image description here

Guess you like

Origin blog.csdn.net/FY_13781298928/article/details/130580242