I need little help making the mesh follow the cursor

Hi everyone,

I’m working on a test project where I load a lens PNG as a texture on a plane and make the mesh plane follow the cursor using a smooth lerp function. Currently, the lens moves, but it stops halfway and doesn’t fully reach the cursor. I’ve referenced a GitHub project for guidance but still need some help to get this working correctly.

Here’s my code: My Code

Original code and demo: Demo Project

The link [My Code] is not functional, when I try it. Generally, you need to do this:

  • when the cursor moves, just record the position as a target position
  • within the animation loop lerp the mesh towards the target position

A Suica-based demo of the concept:

https://boytchev.github.io/suica/examples/events-find-position.html

image

4 Likes

Hello,
It sounds like your smooth Your Medicare Card lerp function isn’t reaching the cursor completely. Ensure that your lerp interpolation factor (t) is set correctly, typically between 0 and 1, and adjust the speed to make it more responsive. You might also want to check if any constraints are limiting the movement range of your mesh.

Best Regards,
James Keen

1 Like

Hey mate thanks for the help, I calculated the target positions and lerp it for smooth movement like you said, and now it works. I’m so sorry I forgot to make the project public, it was on private and now I’ve changed it: https://codesandbox.io/p/sandbox/lens-x9lmrz