December 8, 2019 Custom Camera in Godot, part 2: Follow the Player By Stephen Hull Articles, Blog 11 Comments Related posts: No related posts. Tags:canvas transform, game creation tutorial, Godot camera, Godot camera tutorial, Godot game engine, Godot kickstarter, smooth camera About Author admin 11 Comments GDQuest Today's tutorial, for the first time, features 2 logos at the end. These 2 game studios, Gamblify and Pineapple Works both use Godot and support the developers directly with donations! They picked the sponsor tier on the Kickstarter, and as they're very active in the community (we even met at the GodotCon). Check out their work!Gamblify: https://www.gamblify.com/Pineapple Works: http://pineapple.works/ May 24, 2017 Reply Ramesh Mani Maran save offline May 24, 2017 Reply Gilles Roudiere Hello, Why do you use an offset instead of the the actual position ? Is that for the following zelda-like (let's say "step by step", or tumbling) movement of the camera ? I mean, you could do something like that in the update_camera function:var canvas_transform = get_viewport().get_canvas_transform()canvas_transform = player.get_pos() – screen_size / 2get_viewport().set_canvas_transform(canvas_transform)(This is exactly the same function as the _ready one in the beginning of the tutorial) To be honest, this code lit a light in my computer scientist mind. This method of using an offset (instead of a calculated value) tends to introduce errors in the calculated positions, which may grow over time. This error is known as the round-off error, and actually killed 28 soldier in 1991:http://www-users.math.umn.edu/~arnold/disasters/patriot.htmlHopefully, your game wont hurt anyone. ^^ Anyway, I still enjoy your videos, which makes me think to consider baking your promising project ! 🙂 Thanks ! May 24, 2017 Reply Rettroix 2nd Channel Great tutorial, will you be showing how I can change the zoom of the camera? May 24, 2017 Reply cboittin What's the advantage of having the camera updated through signals instead of having it update itself at every frame with a _process function ? May 24, 2017 Reply William Taylor Don't see your player? If you don't see your player on screen at the end of this it's because they aren't inside the blue box to begin with. Drag the player inside the blue box and everything will work correctly. The next video fixes this bug. May 25, 2017 Reply kinoko Thanks for the really really awesome series! It's helping me a lot! I have a question though:If the last_player_pos is 3, and the current_player_pos is 5, the player_offset would be 3 – 5 = -2. But if you add -2 to the camera position, wouldn't the camera move the other way? I just can't understand this bit and my head hurts 🙁 June 4, 2017 Reply Willy Aguirre I have to put the player in the middle of the screen and works, What kind of witchcraft is this? XD great tutorial!! December 14, 2017 Reply ZoidbergForPresident Two remarks:Code has changed since last video, that's a bummer.And also why not use the same code than in ready function? I don't quite understand why you do that this way. What would be wrong with this code? extends Node2D onready var screen_size = Vector2(Globals.get("display/width"),Globals.get("display/height"))onready var player = get_node("Player")onready var last_player_pos = player.get_pos() func _ready(): set_camera_pos() func update_camera(): set_camera_pos() func set_camera_pos(): var canvas_transform = get_viewport().get_canvas_transform() canvas_transform = -player.get_pos() + screen_size / 2 get_viewport().set_canvas_transform(canvas_transform) January 21, 2018 Reply CloudPunch Could you pls tell me how to clamp the camera? July 22, 2018 Reply John Snevily If you're following this in Godot 3.x, "Globals" singleton has been renamed to "ProjectSettings" June 6, 2019 Reply Add a Comment Cancel reply Your email address will not be published. Required fields are marked *Comment:*Name:* Email Address:* Save my name, email, and website in this browser for the next time I comment.