![]() That caused me a lot of headache, so instead of doing that, I thought this method is simpler and more useful in terms of reusability. This way, you will not need to deal with the boundaries of the world and how the camera will interact with that. This provides a camera that is locked in a particular section. After adjusting the position of the sections, it will look like below:Īnd it will change the camera to the other section as we collide with another section. We will repeat this many times until we cover all the game world. Now the only thing left is to add Section components to our game world. If (body.Name = "player" & camera != null) GD.Print(String.Format("Preparing section. Whenever a scene loads a section, it will call _Ready method, let's see how that goes. Private void _UninitCameraSignal(Node body)ĬameraScene property will be used to load Camera component on the fly and camera property will be used to mutate its properties, such as current property of Camera2D. Private void _InitCameraSignal(Node body) Section component will deal with setting the camera when player collides. The things you need to be sure is to set Anchor Mode to "Fixed TopLeft" so that the camera's origin should be at top-left, which makes it easy to place on game world, and Current to "On" to immediately focus on that camera when the game loads. On the other hand, Camera component is actually a very simple scene, containing only a Camera2D node named camera as root.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |