Character Following Cursor on Screen


How could I code the character in such a way that the object/character would follow the user’s cursor on the screen? I got this idea from the ‘Ice-Skating Game’ in the gallery. Instead of having an object to click on, I want the characters and objects to naturally follow the cursor.


Hi @Ryan_Chen,

we’re working on providing API to make this possible. We’re still doing some internal testing before we make those methods public.

As a workaround, you can use the same logic for the Ice-Skating Game but apply it on items that move along with the camera. Here’s an example:

Show code

Code in action

Scene set-up

To attach items to other items without moving their position, simply click the attach - icon in the item inspector, then click the item you wish to parent them to from the hierarchy.

How it works
We define a dragArea and a dragTarget. Both items are parented to the camera using the attach feature. With the onUpdate block we call the “moveToTarget” function and pass which item we want to move, as well as which item should serve as a target. If the distance between the two items is greater than a certain treshold, we move the item. This is done to prevent the red cube from overlapping our green target.

Example scene to try yourself

Hope this helps!


Thank you so much! I’ve got the code inserted and it works really well


How does this work with the blocks today or now do you have the API for it?