I have a script attached to an AnimationPlayer node and it does some long calculations,
so in order to avoid the game engine from hanging while those calculations take place
I created a separate thread for that function,
but the seek() function doesn't update the animation despite adding update=true
I've narrowed it down to this simple example:
extends AnimationPlayer
tool
export(float,0,1,0.1) var aniTimer = 0 setget aniTimer_Changed;
var thread;
func sep():
self.seek(aniTimer,true);
# calculations #
func aniTimer_Changed(new_val):
aniTimer=new_val;
thread = Thread.new();
thread.start(self, "sep");
here's how the tree looks like:
so how to I get the seek() to work or is there any workaround with what I'm trying to achieve?
Edit:
I tried applied the solution @Theraot gave & modified it to loop through all the animations
like this:
func sep(thread:Thread):
var AnimationList=self.get_animation_list();
for animation_name in AnimationList:
self.current_animation=animation_name;
var ongoing_animation=self.get_animation(animation_name);
for track_indx in ongoing_animation.get_track_count():
for key_indx in ongoing_animation.track_get_key_count(track_indx):
var key_time=ongoing_animation.track_get_key_time(track_indx, key_indx);
self.seek(key_time,true);
Translate=false;
property_list_changed_notify();
thread.call_deferred("wait_to_finish")
func Translate_Changed(new_val):
if _thread == null or _thread.is_active():
_thread = Thread.new();
_thread.start(self, "sep", _thread);
But when I run this for a big animation it gets stuck in between & the entire godot game engine hangs
I'm guessing it's a memory leak?
what am I trying to achieve?
I've actually created custom properties on a node and added those custom properties as keys in an AnimationPlayer
but these custom properties all effect position, rotation & other inbuilt properties.
so I thought by seek() I could see the end result of all them combined and then key the position, rotation & other inbuilt properties to another AnimationPlayer

