Issues using the mouse to move an actor in a side-scrolling game

Hey all,

My little group of developers and I are working on a side-scrolling game in UE4, and we started trying to build this feature. I’ve built and attempted it, and ran into an issue I simply cannot figure out how to fix.

Our goal is to give the player a list of objects to place, spawning the object when chosen, moving the object around with the mouse, and then placing it if they’re able to. I started simply with moving the actor using the mouse, and already ran into an issue that is wrecking my head. The implementation seems to work at times, but randomly the object will shift away from the mouse to odd locations while you are moving it.

I started testing this with the Blueprint Side Scroller template, adding a player controller to the GameMode to use it’s mouse interaction. I have also made a project from scratch, and have the same problems.

For the moveable actor, I copied the Blueprint on MI_Sphere from the Blueprint Mouse Interaction content example, where moving the objects works fine. The only changes I made to the blueprint were to remove the touch controls, and material changes, to reduce it down to the bare functionality I need.

https://docs.unrealengine.com/latest/images/Resources/ContentExamples/MouseInterface/BlueprintActors/MI_SphereGraph.png

This is the Blueprint from the content example that works just fine. I have played around relentlessly with the settings, especially collision, and the Trace Channel, to no progress.

Can anyone give me an idea of what is going wrong? Or, give me a better idea of how to get started setting this feature up? I really cannot tell what the issue is.

I posted the same problem a day or two ago.

https://forums.unrealengine.com/showthread.php?1742-Problem-with-Mouse_Interaction-blueprint

I haven’t looked into trying to fix the BP myself, but it sounds like this is an issue for other users too. Perhaps a Unreal dev could take a quick look and confirm if it is an issue just with the blueprint or if there is something more sinister going on?

I’ve seen the issue you mention in the Blueprint_Mouse_Interaction example. However, mine is a bit different.

In some areas of screen space, it seems to work perfectly, yet in others, it jumps around at random. Still even, it tends to snap to the bottom of the capsule component of my pawn most of the time.

Though I think there is likely a bug in the PlayerController’s mouse controls, the more and more I look into it, the more I think it has to do with the “Get Hit Result Under Cursor By Channel” node in Blueprint. I’ve tried changing the channels, but the only one that works is the ‘visibility’ channel. From what I understand, the visibility channel only returns a hit if the actor is visible to the PlayerComponent. I can’t be sure though, both because I can’t directly see or understand what is visible to the PlayerController, and because the UE4 documentation lacks any information on that node, what difference the channel makes, and even lacks documentation on the PlayerController itself. (The UE4 documentation page for PlayerController consists of 2 sentences)

Fairly soon, I’m going to try just using the mouse x/y position, but I don’t have high hopes.

I saw the jumping around issue in the Mouse_Interaction example too, i just didn’t mention it in my other post. It seems to snap suddenly to places where my mouse isn’t located and this especially occurs when the sphere is dragged around the bottom of the screen or at the edges of that example BP.

It would be good if someone on development team could confirm that this is a problem.

I know this is an old thread but it is one of the top results on Google when I was searching for a solution to this same problem. For others who want a solution it seems adding a background object of some kind (a static mesh or geometry brush for example) behind your object(s) is the answer.

In my project I had playing cards that the player could move around. When I tried to move them using the code from the Blueprint Mouse Interaction Content Example the cards would jump back to 0,0,0 location erratically especially if I moved the cursor rapidly. I had been testing the code in a blank level so the cards were essentially floating in space. I tried adding a Box Brush behind my cards as a large background and everything started working. Tried it with a static mesh too which also worked.

Seems that is the cause.