Left Mouse button pressed and released equivalent in enhanced input (or drag and drop)

Hi!

I’m using Unreal 5.3.2.

What is the equivalent for this in enhanced input?

imagen

Sorry, but I’m blocked.

I think it could be an input action with bool as Value Type.

Thanks!

Just default input with no changes. Use Started/Completed.

bool as Value Type.

It does not matter here. It does not affect the functionality per se, merely spits out a piece of data that can be used for something else.

@Everynone I’m going to test this:

I’m going to use the Hold trigger.

Sure. But that’s not what you want:

image
image

Hold serves a very different purpose.


If you want the equivalent, it’s just a default node with nothing changed, no modifiers and no triggers.

Well, I think I make a mistake.

I want to use the mouse to drag and drop actor while playing a game.

I’ve found your answer here How to click drag/move an actor during runtime play? - #3 by Everynone, and I think you were using drag and drop in there.

But I want to press the left button over an actor, and while pressing it, move it to another place. Finally, I will release the left button.

Thanks.

A default input node with no changes is fine. You can even use the Triggered instead of Tick.

Tick? The tick event?

I think Triggered is the first option, but I’m confused with Tick.

Thanks a lot.

If you want to do something every frame - dragging - you need to update location of the actor every frame. Normally, Tick would be used for that since it executes every frame.

The EI has the advantage of spitting out an update during Triggered at the very top. So you can do the entire dragging system using just the node above. Try:

To see what I mean.

1 Like

OK. I hadn’t seen the Tick event in your answer: How to click drag/move an actor during runtime play? - #3 by Everynone

Thanks a lot.

But again, you do not even need it here.

1 Like

In case there was any doubt:

  • enhanced input with default settings:

  • Drag:

  • Get Hit Actor:

  • Complete Drag

This can be improved. I’d start by isolating collision with channels / object types. Then incorporate offsets based on components bounds so they do not intersect with the geometry they’re sliding on. Plenty of other stuff, too, depending on what this is going to be used for…

I love you.

:blush:

1 Like

I have another question:

How can I move it only in ZY Plane?

When I try to move it up, it moves on the X axis.

Thanks.

In the drag function, we feed it a vector with all 3 XYZ components. You can set X to a fixed value.

Depending on how the whole thing is supposed to work, it might be better to adopt a smarter tracing method. You can get quite consistent result with Line Plane Intersection.

Rather than relying on gemeotry to get hit, you trace against a virtual plane that can be oriented any way you want.

Imagine you have an invisible wall behind those cubes, you can trace against that instead, rather than the floor…

Thanks for your comments, but I haven’t understood anything. Maybe, I need to study more mathematics.

I’ve been trying to don’t move the block when I click on it, but without successful. And also moving it along the ZY Plane with the same result.

I don’t understand what it is a Line Plane Intersection, and why you mention the floor. In the code it seems that you use a line trace to the block, not to the floor.

You asked an additional question:

How can I move it only in ZY Plane?

Line Plane Intersection allows you to create a virtual plane anywhere and trace against it so you do not need to rely on geometry. To visualise it:

Here’s some script allowing for picking up stuff and moving it in a specific plane only we determine ourselves manually:

The green debug plane visualises what’s going on. In short: shoot a beam (trace) from the screen centre towards the projected mouse cursor, when it eventually intersects that plane (which is infinitely large), place the actor at the intersect world coordinate.

If I change the normal:

You could derive this Normal from the actor itself instead:


Or you can get it from the surface in the world - tracing returns a Normal, you do not need the virtual plane then:


I haven’t understood anything

Set up a new project, replicate the above, experiment, see what you can learn. At some point the whole thing will click.

1 Like

Thanks a lot.

It works perfectly. Sometimes it seems that the cube rotate, I don’t know why.

Before I drag it:

After:

Let me check what it’s happening.

A single axis has too much ambiguity, you may need to build your rotations from 2 or 3: