#Problems with mobile performance when attack or move player - 60 to 45 fps
63 messages · Page 1 of 1 (latest)
can you benchmark how long different parts of your script take?
https://docs.godotengine.org/en/latest/tutorials/scripting/debug/the_profiler.html
and you can just add some simple start/end time diffs on different parts of the code.
then figure out what is causing the FPS to drop
You run your game from Godot and play around. It's fun, it's becoming feature complete, and you feel it's getting close to release. But then, you open the skill tree, and it grinds to a halt as som...
This happens when i do tap in mobile
you have a spike, now go into the code and add start_time and and_time
https://www.reddit.com/r/godot/comments/1cepfjp/calculating_elapsed_time/
and check what is causing the issue
im still investigating the issue seems weird for me since im new into creating videogames but thanks for guide me bresk
ok so i decide to start over again with all the project from scratch
first of all i would like to ask
is any way to be able to push content into my github from godot directly?
i was trying to use codex to help me but starts to crash at the point of make pull requests
@long plank
It should be possible - look at some tutorials on YouTube
nah bro even with just 400 tiles or 40 still happens the same
first map 4000 tiles 60 to 45 fps just by doing click
400 same
and 40 same
mobile
so i can´t understand where is the problem....
so this is happening me when i touch the screen in the mobile
how can i fix that process time?
Tick the Process Time and try to find what method's being called that's eating up all the time.
thats why im asking how to
i can´t find the problem
i mean just happens when i tap the mobile screen
Keep in mind, _input() is called ANY TIME there is a change in input, mouse movement and touch screen inputs produce a LOT of events per second.
if you run heavy stuff in _input(), it is going to tank performance.
You should only use _input() to retrieve information about inputs and not much else.
func _input(event):
if tapped_this_frame:
return
if event is InputEventScreenTouch and event.pressed and event.index == 0:
tapped_this_frame = true
var target_tile = Vector2i(event.position / TILE_SIZE)
var current_tile = Vector2i(position / TILE_SIZE)
if target_tile != current_tile and target_tile != last_requested_tile:
last_requested_tile = target_tile
Pathfinding.find_path(current_tile, target_tile)
func _process(delta):
tapped_this_frame = false
find_path() sounds like a heavy call
When you click on the timeline for the profiler do you see anything showing up on calls in "Script Functions" that take up time?
no
func find_path(start_tile: Vector2i, end_tile: Vector2i) -> void:
if is_busy or not astar.region.has_point(start_tile) or not astar.region.has_point(end_tile):
emit_signal("path_ready", [])
return
is_busy = true
pending_start = start_tile
pending_end = end_tile
thread.start(Callable(self, "_thread_find_path"))
func _thread_find_path():
var result := astar.get_id_path(pending_start, pending_end)
call_deferred("_finish_thread", result)
func _finish_thread(result: Array[Vector2i]):
if thread:
thread.wait_to_finish()
is_busy = false
emit_signal("path_ready", result)
func _exit_tree():
if thread and thread.is_started():
thread.wait_to_finish()
this my pathfinding.gd
this looks pretty light, altho i never use threads myself.
I assume that you already know that threads have their own overhead, as they need to synch up with the main thread at some point.
yes
im struggling on how godot export games to android mobile.
why process time is so high just for tapping the screen?
if i dont have nothing in my code to do anything
Surely it should show up in Script Functions if it is this, unless the thread stuff is somehow tucking it away. ;\
As an example
thats a mobile game tap based?
No, I'm just showing where to look on the profiler.
My main M.O. for finding performance hogs is commenting out specific lines of code and see which has the best result in lowering frame time.
Start trying to block _input() entirely.
If that works, block the heaviest lines on _input() until you find the most effective one.
Sadly, if the profiler is not helping, your best bet is a binary search.
What it should definitely show is a bunch of calls to get_path
oh nah i told u my scripts are not the problem.
It could also be an issue with USB devices, there is a very weird and persistent bug where USB devices with certain IDs can cause very strange hiccups, both when loading and processing.
i think is more like a version of the godot problem.
Moving them around ports tends to fix it, assuming you have more than 1 port
mmmm i will try something different instead of usb connection or wifi connection.
I think i will put again the code to move trough the map and test it just by exporting
not debuggin
To be fair the profiler in Godot is kinda meh.
if i see like lag spikes is still a problem.
if dont then i know where is the problem
in Godot
and i assume i would need to go to github issues
to let them know this problem
i mean, it probably is in Godot
But hopefully there is a fixable source of it
Thanks guys i will come here when more news about this comes.