Hi folks!
I’n quite new to Godot. I have a question. I’m trying to make a simple Dungeon Crawler game and I crashed right at the beginning. I have tis script for the movement:
extends Node3D
But there is an issue with the “var move distance” I discovered the value just by trial/error. But whenever I change the window size, the value is not valid anymore (steps are much longer with bigger screen size). How should I change the script to make 1 m steps no matter what screen size I use? (For the simplicity, the size of the “game unit” is 1 m…)
Thank you in advance
Please update your post with proper formatting using ``` for code snippets.
Also, you mentioned “var move distance”, but it’s not in the code anywhere. What do you mean?
If you don’t want to scale then you could probably use the Window class to get the window size and use that to calculate your move_distance. However, I’m not sure if this is the best/easiest way.
Thank you so much! That was it (the first method). Although I don’t know where does the final value of the move _distance = 240 come from. It has nothing to do with the GrigMap3D cell size, nor the size of the tile…
Could there be another approach? Because according your answer, the distance walked in one keypress could change in more / less complicated scenes. As well as with the change of the resolution. Simply put, the engine isn’t capable to walk exactly 240 pixels/second in every situation… Does it also mean that on a faster computer (mine isn’t any killer machine), the value of move_distance should be different?
The delta parameter in the _process() function refers to the frame length - the amount of time that the previous frame took to complete. Using this value ensures that your movement will remain consistent even if the frame rate changes.