The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

Hi,

i'd like to have Zelda-Like moveable Blocks which can be pushed.
While they are being pushed, they should be animated lke they're vibrating/shaking.
Can this animation be done by adding a Tween (how?), or should i go for 'updating to random positions while a Timer plays'.
What is the better approach for this structure..?
- KinematicBody2D
| - Sprite
| - CollisionShape2D

Thx4reading!

in Engine by (41 points)

1 Answer

+1 vote
Best answer

Assuming the shaking is just for visual effect and doesn't actually impact game play or the interaction with the blocks, why not simply animate the sprite object itself? As an outline:

  • Create a suitable "shake" animation for the block's sprite
  • Set it to loop
  • When the block push starts, play the animation using $AnimationPlayer.play("yourAnimation")
  • When the block push stops, stop the animation with$AnimationPlayer.stop()
by (22,674 points)
selected by

Thank you, to pick the Sprite Child is the key! (Because I'm already using AnimationPlayer to change position of the KinematicBody2D, changing the sprite's position doesn't affect the rest like the collider etc...)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.