Having Game Object Avoid Cursor

Hi,

I want to create a fun 2D Menu where when the player clicks on the play button it begins to elude the cursor and move around. The player will be tasked with trying to click on it but it continues to elude the player.

Any ideas on how I can go about coding this?
Thanks!

Add bigger collider to the button and cast a ray from camera through mouse position. If hit that collider, calculate distance from cursor to object center (use renderer bounds or collider center if pivot is not good for this) and apply acceleration based on that distance.

1 Like

Don’t need physics or raycasting if you already know the position of the object and position of the cursor. Otherwise you’d want a Flee Steering Behavior

2 Likes