Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | muralis923 |
Trying to topple enemy game object’s instance when got hit by player’s bullet.
Animation works but the toppled game object global_transform.origin changes to the last enemy game object’s instance global_transform.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.
do you have a single animation node or an animation node for each enemy?
Andrea | 2021-01-20 15:34
I have one single enemy object in which i have the animation player node. I added multiple instances of this enemy object in to the main scene.
main scene screenshot
Untitled.png - Google Drive
Enemy game object screenshot
Thanks.
muralis923 | 2021-01-21 07:55