
The next interesting game mechanic were the way the grubs run away from your mouse when you try to catch them. I wrote this avoid mouse function, and I ended up getting obsessed with it and making the main mechanic of Wild Thyme just because it felt so silly. Now it looks really basic and simple, but at the time it took me a while to figure out, especially the global mouse position.

var flee_distance: float = 100.0
# Flee from mouse var mouse_pos = get_global_mouse_position() var distance_to_mouse = global_position.distance_to(mouse_pos) if distance_to_mouse < flee_distance: direction = (global_position - mouse_pos).normalized() current_speed = fast_speed else: current_speed = speed
# move position += direction * current_speed * _delta
Unable to load video.
0:00 / 0:00
