Moving a node with your finger!


Hello! I’m new to scripting in and a modest programmer, so thanks in advance for your patience.

I would like to get into touch events, and want to start by moving a plane with a finger drag. Please note that I want to be able to move objects directly and not use the 3D Photofeature function.

I have a pointmove script for the plane with this script in it. I’m trying to access the array of the finger position using e.localPosition and feed that into the position method of the plane. I think the error means a variable type mismatch. Can anyone help?

parent.on(“pointermove”, (e) => {

var fingerPosition = ([e.localPosition]);

//Error thrown: Argument of type number [][][]`` is not assignable to parameter of typenumber []., //Typenumber []` is not assignable ot type number.



To correct your error you should write:

var fingerPosition = e.localPosition;

but I don’t think it will work the way you want… :slight_smile:


Thanks so much. Is there a better way to move an object around by touch?


There is a problem because pointer is in 2D and the plane in 3D,
So a way, can be to “insert” the x,y of the pointer inside the 3D coordinates of the parent and keep the z value…

parent.on("pointermove", (e) => {
var fingerPosition = e.screenPosition;  // pointer position: x,y
var parentPosition = parent.position(); // plane position: x,y,z

parentPosition[0] = fingerPosition[0]; // replace the x
parentPosition[1] = fingerPosition[1]; // replace the y



This worked! Thanks.

The odd thing is, the drag feels really unnatural. I’ll play with it to see if I can add a more realistic motion.

I appreciate your interest and help!


this code not working, while i am dragging the Plane, some time it not dragging , it stop working randomly, Do you have any idea ?
i am using iPhone.
Best regards.


Do you have anything else in your project, beside the image you are moving?


yes i have but all of them are enabled(false).
when i touch one plane, i disabled all the others.
what i noticed that if i make the plane bigger, then it will work better
Do you have any idea ?

Thank you for your respond .


this is working for me, i made scrollbar using same script with little modification


Hello, what modifications did you make ?, I can’t make the object follow my finger, it only does it randomly, can you help me?