help me to move object by mouse or touch

hi

iam working on a game and i want you please to help me , i have an object “Bucket” and i watched a video hot to move it by keyborad, but i want to change the code and move the Bucket by mouse or touch ( im working on this game and i want to make it available for mobile phones, so i dong know if i need a mouse drag function or touch function) and i want this Bucket just able to move right and left directions , please help me at this case :(:frowning:

Regards…

please any one can help ??

In your bucket script, create a function called OnMouseDrag(). Set the transform.position of the bucket to the position of the mouse. You may have to translate the mouse coordinates to world coordinates.