+1 vote

hello! I'm following this tutorial here on automatic camera limits:
https://www.youtube.com/watch?v=zdi7HlpRrSg

And it seems that there is some misunderstanding on my part on how the getusedrect() script works.
Just like the video, here is my code:

var tilemapRect = get_parent().get_node("Ground").get_used_rect()
var tilemapCellSize = get_parent().get_node("Ground").cell_size
$Camera2D.limit_left = tilemapRect.position.x * tilemapCellSize.x
$Camera2D.limit_right = tilemapRect.end.x * tilemapCellSize.x
$Camera2D.limit_top = tilemapRect.position.y * tilemapCellSize.y
$Camera2D.limit_bottom = tilemapRect.end.y * tilemapCellSize.y

however when I print out the values of tilemapRect, it prints out this:

(-1, -1, 97, 33)

now to my unerstanding, it returns a value based on tiles, like for example top goes based on the top left most block, and returns its position on the tile grid.
This is correct for the top and left side, which the top left most is -1,1. However the problem arrises with the right side, where it is 97, 33. I don't have a block on this position, yet it prints that I do, and calculates based on this and goes way to far right and way to far down. Have I done something wrong, or is there an issue here?

enter image description here

Godot version 3.2.3 stable official
in Engine by (36 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.