0

How can I animate a 3D actor at current location, and have it not snap to origin?

Hey, was wondering what a decent solution for fixing an animation issue where when I define a anim within an 3D kinematic body node (my player) and want to play a damage animation defined within that Node, Call it in my level scene with

func _on_Enemy_body_entered(body):

# Console Printout Replace this with GUI & game Anim

#print("Damaged")

$AnimationPlayer.play("dmg")

Animation Plays on level but Node snaps to origin to play I want animation to occur at current player location, how do I add player transforms in a level scene to animation defined within that Node?

I've heard that parenting it to an empty helps, tried it and though I can offset where anim plays it still snaps far from the player location.

I've also seen 'tweening' node might be a possible solution?

TL:DR How can I animate an actor at current location, not snap to origin?

Xavier R
  • 1
  • 1
  • Not sure how much this helps for your specific scenario, but you could keep the (playing) animation player as a child of the character, and set it to hidden (not visible). Then, when the player takes damage, you could call `$AnimationPlayer.show()`. Also, If you only want it to happen for a certain duration, link the trigger (damage) event to a Timer, and set it to call `$AnimationPlayer.hide()` after whatever time interval. I've used this approach to to play a "jet flame" animation when a ship is accelerated. – Christopher Bennett Dec 12 '19 at 01:43

1 Answers1

0

You will have to animate only the children of the KinematicBody node. So that the origin of the animated node is the global position of the KinematicBody.

For example, a hurt animation should animate a MeshInstance that is under the KinematicBody and not the KinematicBody itself. You may want physics to apply to the KinematicBody that go along with the hurt animation which you can call with a animation method track.

You can also try the "Capture" update mode for an animation player track. Which will capture the state of the animation target and interpolate it to the next keyframe. This wouldn't animate relative to a location though.

hola
  • 3,150
  • 13
  • 21