Trying to topple enemy game object's instance when got hit by player's bullet.
Animation works but the toppled game object globaltransform.origin changes to the last enemy game object's instance globaltransform.origin. When the animation starts to play the enemy game object instance 1 is positioned at enemy game object's instance no.2's position and ends the animation there.
I used only two instances of the same enemy game object. The following code is in the script of the enemy game object.
func configAnimation():
var anim = $AnimationPlayer.get_animation("Topple")
print(anim.get_track_count())
#print(anim.track_get_key_value(0,0))
#print(anim.track_get_key_value(0,1))
var p:Vector3 = self.transform.origin
print("p " + String(p))
var p1:Vector3 = p
p1.y = p1.y + 2
print("p1 " + String(p1))
anim.track_set_key_value(0,0,p)
anim.track_set_key_value(0,1,p1)
anim.track_set_key_value(0,2,p)
I connected the animation_finished signal to the AnimationPlayer node and got the position of the game object instance number one starting and ending the animation at the position of game object instance number 2.
The Output is like this:
1
p (14.8615, -4.71206, 0)
p1 (14.8615, -2.71206, 0)
1
p (10.2427, -4.71206, 0)
p1 (10.2427, -2.71206, 0)
Anim Finished
(10.2427, -4.71206, 0)
Any suggestion will be helpful. Thanks.