Download

Drag n Drop actors ingame (not using physics stuff)

ive written drag n drop logic in 2d based engines and its usually something like :



// on click
DragOffset = Mouse_World_Position - Object.Location;

// while moving in the update tick
Object.Location = Mouse_World_Position - DragOffset


ish

i tried something similar in blueprints :



// onclick
DragOffset = ConvertMouseLocationToWorldSpace() - HoveringActor.Location;
SelectedActor = HoveringActor;

// while mouse is held and update(dt)
SelectedActor.Location = ConverMouseLocationToWorldSpace() - DragOffset


this works, but the object only moves a little bit
i assume ive missed something in regards to the mouse’s world position (projection/deprojection stuff)

any pointers?

maybe you should ask the c++ stuff in the c++ forum :smiley:

but for the little bit movement are you should try to use the mouse_move event rather than a mouse_down

hi ruohki, that’s not c++, and it was just psuedo code for what i have done previously, and what ive currently got setup in blueprints
i shall check out the mouse move event, cheers

i couldnt find mouse move event in bps

if anyone has any ideas about this drag and drop in an isometric view, that would be really helpful :slight_smile:

ok, i have a version working…
but due to the Isometric view & my approach to coding this, the object isnt always under my cursor

my approach was this :
find mouse location in the 3d world on the “floor” of my game. the “floor” being Vector.Z = 0
this meant that when I did my dragging, I would simply use this vector

*edit to added bpfiddles:
– finding mouse location and saving
http://bpfiddle.com/9678652479/

– update location
http://bpfiddle.com/6B4F591A/

i assume this is the completely wrong approach, and any suggestions would be greatly appreciated :smiley: