Camera+Movement without a character

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Irrelevant Person

hey, I ´ve started making a game(2D) and its … kind of strategie, so I want to make a camera, which does not have a character, just to move by a pressed key.
Is it possible to do it without an object, that is binded to the camera?

:bust_in_silhouette: Reply From: Magso

It depends on your setup. For this the camera would have to be separate from the player and check if a player exists using get_nodes_in_group() or have the player tell the camera script when it is following it and use a bool to toggle the cameras free movement.

:bust_in_silhouette: Reply From: tastyshrimp

The Camera2D object is a child of Node2D, meaning it can be moved based on it’s transform. Very similar to how the character on the Your first game tutorial in the docs.

This. The camera can also listen to events and do some actions based on inputs, so you’d just add the player script to the camera instead.

nwgdusr999 | 2019-12-26 18:53

:bust_in_silhouette: Reply From: zen3001

I was working on top down rpg recently with a free camera as well, and I found it to be usefull to make the camera a child of a hidden kinematic body. It should be still possible to do it without the kinematicbody but this makes it alot easier to avoid the camera going into places it’s not supposed to.

That is one different way to do it, but i guess it would work. But by default you just clamp the camera to a min/max X and Y coordinates and be done with it. Of course the assumption is that your map/camera limits is a rectagle.

tastyshrimp | 2019-12-26 18:59