0 votes

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 (39 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 (12,282 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 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 webmaster@godotengine.org with your username.