+4 votes

EDIT: So it seems there is no simple fix for this? I've submitted this as an issue on the Godot GitHub, so we'll see what happens. But! I am open to hearing any tips you all have!
/EDIT

Hi everyone! I've been using Godot now for a few weeks and it's awesome! Very intuitive and well-made software. Thanks to everyone working hard on it and all those helping others.

My question: Is there a way to change the default select-able area of a node? I like to make lo-resolution pixel games, and it seems many nodes select size (Node2d, kinematic body, area2d) default to 64x64. I might be missing something very obvious, but here's an image of my test game I'm working on:

enter image description here

The tile size is 16x16 and it gets very difficult to select the right thing (though the drop-down select menu helps!) Is there any way to get the select area to be like the image on the right? The player root in this case is a kinematic body, but I have the same issue right now with area2d and node2d.

A few things I've tried:

Make the sprite the root node -- It seems this is not suggested practice and I imagine it makes it difficult to keep the sprite synced to the hitbox, rotation, etc.

Scale the root node down -- this scales down every node it's a parent of, so it's a no-go. Or is there a way for child nodes to ignore the parent's scale? And I don't see a size box for kinematic/area/node2d nodes.

If there is no solution, might I suggest a feature? Maybe in the project settings there could be a "default node size" that you could set? It would help making lo-res pixel games a ton if it was possible to work in the game's tile-size! Or maybe add the ability to choose the size of these kinds of nodes, independent of scale.

Sorry for the ramble, and thanks in advance!

in Engine by (19 points)
edited by

Okay, cool. It seems there is no way to change the size. Your issue settled on snapping nodes to center but this problem would still be there -- maybe I should submit my issue -- setting a default node2d size -- as a request on Github as well? Thanks!

1 Answer

+2 votes
Best answer

You can override Rect2 CanvasItem::_get_item_rect() in your node script.

Assuming the node is a CollisionObject2D or any other node with a Sprite as child, you can do this:

func _get_item_rect():
    return get_node("my_sprite").get_item_rect()

Your script must have tools enabled.

by (488 points)
selected by

Yes! This works well! I still think it'd be neat to be able to set a new default, instead of manually overriding every object, but this helps so much!

Thanks :)

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.