I'd create a scene/node just for that.
Call it Shaking
or something. Move your code and Timer
node here.
When the character gets hit, call:
character.add_child(Shaking.instance())
After 0.5 seconds when the Timer is up, queue_free()
the node.
This way, the character scene is cleaner.
This also applied to other effects like powerups: speed-up, invincibility,...