[SOLVED] Dragging multiple images to Specified locations

Hi!
I am working on a project that involves dragging multiple images on a 2D screen to different locations with a mouse. However, when I implement:

MouseDragLvl2.prototype.onMouseMove = function (event) {
    if (this.selectedPart != undefined) {
        var depth = 0;
        var cameraEntity = this.app.root.findByName('Camera');
        cameraEntity.camera.screenToWorld(event.x, event.y, depth, this.pos);
        this.selectedPart.setPosition(this.pos);
    }
};

all of the images go a point on the screen. Also, the controls are very inaccurate.
Could you please help?

Thanks

Hi @grwthemonster and welcome,

How are you handling image dragging? Your code mainly shows changing the position of this.selectedPart. I assume that’s an entity?

Try sharing some more info about your setup or if possible share your project to take a look.

In case it’s of help here is an example of draggable elements using a helper class included in the PlayCanvas engine:

1 Like

Nevermind, I got it. Thanks anyways!