Hi Godot People..
i want enemy to pull back after it gets hurt (on both x and y axis). i write this code in process function. but it seems after feeling the punch and when it's going back and reach player "y" axis point, it doesn't move on y axis anymore and it just go back on x axis. beside i should hold the hit key in order to enemy goes back, if i just press and release the hit button, enemy stop after releasing the key, which i think process function is the reason, but if i want to move the code to input function, there is no any delta for changing speed of pulling back. what should i do to make it right? thank you :)
(Godot v2.1.5)
(i created dizzy boolean variable, because i thought pulling back sync with specific animation length ("Hurt"), but it didnt fix this problem)
if animations.get_current_animation() == "Hurt":
dizzy = true
if dizzy == true:
dizzy = false
if (self.get_global_pos().x>enemy.get_global_pos().x):
if (self.get_global_pos().y>enemy.get_global_pos().y):
self.move(Vector2(self.get_global_pos().x-OS.get_window_size().x/10,
-self.get_global_pos().y-OS.get_window_size().y/10).normalized()*speed*delta)
else:
self.move(Vector2(self.get_global_pos().x-OS.get_window_size().x/10,
(self.get_global_pos().y-OS.get_window_size().y/10)).normalized()*speed*delta)
if (self.get_global_pos().x<enemy.get_global_pos().x):
if (self.get_global_pos().y<enemy.get_global_pos().y):
self.move(-Vector2(self.get_global_pos().x-OS.get_window_size().x/10,
-self.get_global_pos().y-OS.get_window_size().y/10).normalized()*speed*delta)
else:
self.move(-Vector2(self.get_global_pos().x-OS.get_window_size().x/10,
(self.get_global_pos().y-OS.get_window_size().y/10)).normalized()*speed*delta)