Topic was automatically imported from the old Question2Answer platform.
Asked By
argames
I am currently creating a top down game for my first project and the character is moving equally to global mouse position. How can I move the mouse back (basically a knock-back effect) every time the player will get hurt as an indication of getting damage? Thank you and sorry for my bad English, I do hope I managed to get my point across.
# at top of script
const KNOCKBACK = Vector2(-20, -20) # or some other value
# in function somewhere
get_viewport().warp_mouse(get_global_mouse_position() - KNOCKBACK)
Hey thank you so much! I got it to work! I will search if I can make it to work together with the angle of how the mouse approaches the trap/obstacle. Have a good one!
This is the effect by the way for those who are wondering: