Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

I like the idea, cool game! Do you happen to have a link or guide to how you achieved the effect of the staff following the mouse cursor around the character? Very crisp and smooth animations, nice work

(+1)

Thanks! Added a StaffSprite as a Sprite2D and the following code. I might be missing something but this should be the majority of the code.


@onready var staff_sprite: Sprite2D = $StaffSprite

var aim_direction := Vector2.RIGHT


func _physics_process(delta: float) -> void:

var mouse_pos = get_global_mouse_position()

aim_direction = (mouse_pos - global_position).normalized()



func _process(delta: float) -> void:

var body_center_offset = Vector2(0, -8)  # center of player body

var line_length = 20

var cut_off = 12 #i started with a red line at first, not sure if cut_off and line_length ended up being used for the final code

# Position the wand along the aim direction

var wand_offset = body_center_offset + aim_direction * line_length

staff_sprite.global_position = global_position + wand_offset

# Rotate the wand aroudn the player to face the aim direction

staff_sprite.global_rotation = aim_direction.angle() + deg_to_rad(45)  # I rotated the rotation by 45deg to match the true direction

(+1)

Awesome, I did not expect the whole code block, thanks! Keen to play around with this