How do i move objects by holding mouse key?

Hey im new into babylon. I come from unity where every object i create has an update function which triggers update every frame only for that object which allows me to check for mouse button hold and move object towards cursor while mouse button is held.

Is there equivalent method in babylon? As far as i saw there is mouse hold and mouse up, but the thing i want to achieve is movement similar to Diablo like games. while button is held → move to target, and stop moving if button is up.

Hi and welcome on board!

Is this what you are looking for:

hey. Thanks for response but thats not exactly what i mean

I want to make my object (for ex. box) start moving towards cursor position while holding mouse key and stop moving when i release mouse key up.

my example is a half way to your desire.

take the red mesh as a “ghost” (or target) and let the object you clicked on look at the direction of the “ghost” and let it move slowly in that direction.

example for key operations:

example for vector calculations:

1 Like