6/14/2023 0 Comments Godot camera2d![]() The true strength of the Cinematic Camera 2D plugin is the ability to create smooth transitions between cameras.Īdd another VirtualCamera2D node to your scene and try changing some of its properties like the 'Zoom' or the 'Offset' values. Note that the camera won't move while in the editor, but only while the game is running. If you want your cinematic camera to follow the player, go to the VirtualCamera2D node and set the 'Follow Node' property to your player node. The cinematic camera mainly does two things for you: updating the camera properties and following another node. If you modify the properties of the VirtualCamera2D node, you will see that you camera will now smoothly transition to these values, even while in the editor. Now go back to the CinematicCamera2D node and set the 'Virtual Camera' property to the VirtualCamera2D node you just added. This node contains all the properties that are used by a cinematic camera. Open the "Create New Node" menu again and this time look for a "VirtualCamera2D". You will see that this node has one more property than the basic camera, that is a node path to a VirtualCamera2D node. Open the "Create New Node" menu and search for "CinematicCamera2D". It extends the Camera2D node and needs a reference to a VirtualCamera2D node that can be assigned to it through the inspector or with a script. The CinematicCamera2D node is the camera itself. It controls the movement of a camera and its settings. The VirtualCamera2D node is a virtual camera. Both can be added to your scenes as nodes through the "Create New Node" menu. The plugin contains two scripts: virtual_camera_2d.gd and cinematic_camera_2d.gd. Please consider supporting the project with a donation if you like this plugin!Ĭonsider also trying my games: Plugin contents You can find the version for Godot 3 here SupportĬinematic Camera 2D was developed by HexagonNico. This is the Godot 4 version of the plugin. This repository contains the plugin files and a demo that shows the usage of the plugin. Here we are telling the Tween to move the "position" of the camera, from the current value of camera.position to the current value of camera_target.position, in the span of seconds.Cinematic Camera 2D is a plugin that adds a 2D cinematic camera that can be used to create smooth transitions between cameras. Tween.interpolate_property(cam, "position", cam.position, cam_target.position, seconds) Which in this case I will go ahead and create from code instead of adding it in the editor: export var cam_path:NodePath Then in code use body.is_in_group("group_name") to check.Īnother thing you can do with this is to tween over time the camera position instead of changing it instantly. You can add groups to nodes in the Node panel on the Groups tab. Also, a common approach is to use groups to discern between the bodies. I'll also remind you that you can use the collision layers to filter what the Area2D detects. Var cam_target := get_node(cam_target_path) as Position2Dīy the way, you can use the same approach to teleport the player character. ![]() Var cam := get_node(cam_path) as Camera2D Well, add some Position2D nodes to mark the position for the camera, and then we can do this: export var cam_path:NodePath Now, you should be able to select the old and the new camera in the inspector panel.Īlright, but we don't want to change cameras, we want to move the camera. Something like this: export var old_cam_path:NodePathįunc when_body_entered(body:Node) -> void: And set current to false for the prior camera.Īlright, if you are going to have references to the cameras in your script, you may instead export some NodePaths for them. ![]() Then on the handler for "body_entered" signal of your Area2D you can set Camera.current = true for the Camera2D of the next room (areas of the map). ![]()
0 Comments
Leave a Reply. |