this post was submitted on 18 Sep 2024
1 points (100.0% liked)

Godot: The open source game engine

21 readers
1 users here now

A community for discussion and support in development with the Godot game engine.

founded 1 year ago
MODERATORS
 
This is an automated archive made by the Lemmit Bot.

The original was posted on /r/godot by /u/SluttyDev on 2024-09-18 18:05:58+00:00.


This is a "Dont feel dumb if you get stuck on something, it happens to everyone know matter how long you've been developing." post.

I was starting a new mobile project and ended up with a weird issue where I couldn't get the hardware to match what was being seen in the editor. The editor showed correct resizing behavior, the hardware did not. I messed with all the aspect ratio and stretch settings but nothing allowed me to fill the background on the mobile device without pinning it to the upper left, which wasn't acceptable.

My usual workaround for this kind of thing is moving the camera to the center of the playfield but didn't work for some reason, I asked all over the internet with no answer (expected, it's a pain to get games loaded onto mobile devices so most people don't look into it). After days of looking for a solution I eventually gave up, switched to Unity, and started building my game in Unity...

...until today when I decided to try once more. I tried parenting my camera to an empty Node2D and moving that around...weird, the camera isn't following the Node2D...why not? After tons of digging through the docs for some setting, and looking at a few YouTube videos I saw it...

...I saw a script attached to my camera...I don't remember why I had a script attached to my camera so I opened it to see what was in said script.

position = $"..".get_viewport().canvas_transform.get_origin()  

Oh...oh my...omfg.....WHY!? What the hell was I doing and why didn't I delete it!?

Needless to say removing that script and doing my center camera thing worked just like expected. I got it building to device with the expected stretching, and I'm moving back to Godot. (Nothing against Unity, Unity 6 is nice but it takes so long to iterate and develop in Unity compared to Godot and my time for gamedev is limited, and I still can't get touches working with Unity's new input system so...)

I've been programming since the 90s. My first games were written in C, C++, SDL, and OpenGL and I'm a professional software developer during the day.

TL;DR: It doesn't matter how much experience you have, sometimes the stupidest little thing will trip you up.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here