Godot Version
4.3.3
Question
Hello there, hope You’re having a great day today. Still working on my little Tower Defense game and I hit a small wall that bugged me out. Basically today I was experimenting and trying to create a building manager but I ran into some issues with my camera. The game is 2D and I want to have a camera for some of the larger levels that I want to create. So I created a Camera2D node and just added it to the Scene so I can just move left and right with the mouse.
extends Camera2D
var speed = 500
func _ready() -> void:
pass
func _process(delta):
var viewportSize = get_viewport().size
var mousePos = get_viewport().get_mouse_position()
if mousePos.x < 10:
position.x -= speed * delta
elif mousePos.x > viewportSize.x -10:
position.x += speed * delta
if mousePos.y < 10:
position.y -= speed * delta
elif mousePos.y > viewportSize.y -10:
position.y += speed * delta
This is my camera code so far but it goes out of bounds since the first level is quite small. I tried to clamp it to the size of the screen that the level is on but on start the screen had only the left part of the map while the other part.
Will still google around to see if I can find a solution but wanted to post here just in hopes someone has an idea for this issue.