Paper2D Sprite Click event not consistent

Hi,

There is an issue with Sprite Component when Click/released/touch event are not consistent compared to static mesh.

I used the code from the content examples to make the drag/drop event in my blueprint.
If I use this code on a Sprite and move the mouse too fast, I “lost” it and the “Hit result under mouse” send location 000.
If I use the static mesh I have the perfect location.

You can use the attached project to repro the bug. The sphere object is works perfectly but for the sprite it doesn’t work.

I look at most of the parameters and can find why there is a difference except a “bug” somewhere.

Thanks for your help.
link text

Hello,

The blueprint provided appears to be working as intended. I noticed that you are not accounting for when there is not a hit location being returned. This is why your objects are getting set to the center of the screen (it’s getting a hit result of 0,0,0 because none is returned). Using a branch to check to see if the hit result returns true should help get you pointed in the correct direction. I hope that this information helps.

Make it a great day

Hi,

thanks for the answer. What I don’t get, is how the hit can be 0,0,0. At each tick we are moving the sprite on the current mouse location, how on the next tick does the hit do not catch the sprite again? Does that mean that between 2 tick my mouse move to far away?

Is there any other approach to get this working? My game is mostly based on Drag n Drop, and this behavior is not what I expect to be in my game.

The worst things in our case is if we “lost” the sprite and it goes to 0,0,0 the released event will never be called.

Thanks for your tips!

I have provided an example below using the project provided. This setup will drop the object in its last position when the mouse is no longer over it as well as reset the object so that it needs to be clicked again to be picked up. I hope that this information helps.

Example:

Thanks for the tip, but it’s kind of hacky and won’t work in my game.

I need the player to frag from point A to B. If it’s release in the middle, it go back to A.

The real question is why are we loosing, the dragged object. What can affect this?

The reason you are not getting a hit result is because the the mouse travels further than the size of the object being dragged before the position is updated in the next frame. This means that the mouse will no longer be over the object when the next hit location is called for and so does not return a hit result.

I understand this.
But, if I put a full screen background, I have the same issue where the location provided by the function is not under the mouse.
That’s mean that the hit happen on a background object so the X & Z value should be correct to set the actor location but it’s not.

How can you explain this?
I came to the same conclusion before opening the bug report, but as putting a background object was not sufficient, I’m a bit lost.

I did try also to no use hit value but mouse position using deproject screen to world, but the function give me coordinate that are correct also…on the current example, from left to right screen border, it give me 140 to 160 range where as we are -210 to 600+

Thanks,

Ok found how to solve partially this.

1 - I did managed the drag object on the PC side and not on the Object it self.
2 - My background need to be near to the the object on Y axis to be sure that when the background is “hit” the value of location will be good for the sprite.

It’s not the best things, but it could work like this.

I think stuff need rework on those events to avois hack like this^^

I am happy to hear that you were able to find a solution to your issue. Thank you for your time and additional information.

Make it a great day