Godot Version
v4.2.stable.official [46dc27791]
Question
When I place a 3x3 pixel art object (a tower) on or near an exact integer position on either the x or the y axis, it gets messy and looks nothing like it should. I’m really not sure how else to describe it so here’s some pictures.
The tower should look like this, and does whenever it is placed not on an integer position
If I travel directly along the x or y axis from where the player character (the vehicle) starts, and place a tower it looks like this
or this
Both of these are on exactly 120 on either the x or y axis
This is the code that determines the position of the tower when it is placed.
func _ready():
position = $/root/Main/Vehicle.position
If I make it always place on an integer position by using int(round(position.x)) and int(round(position.y)) then it always appears like one of the previous images as opposed to only sometimes.
The problem goes away completely if I just do this
func _ready():
position.x = int(round($/root/Main/Vehicle.position.x)) + 0.1
position.y = int(round($/root/Main/Vehicle.position.y)) + 0.1
But that’s ridiculous and I’d quite like a better way of fixing it.
Here’s the settings that I could imagine are related to this problem:
- Viewport is set to 240 x 240
- Stretch mode is viewport
- Stretch aspect is keep
- Stretch scale is 1
- Scale mode is integer
It’s not a project-ruining problem by any means but I am absolutely baffled by it. Maybe it’s just because I’m quite new to this and I’m missing something simple. Any ideas, solutions would be lovely. I’m also happy to provide more information if I missed something relevant. Thank you!