How to control an object's position with your mouse

Sorry for the super simple question, but I’m just starting and still trying to figure out the basics and after looking for a while I haven’t found a good solution for this.

I’m making my very first game to learn the ropes, an air hockey clone, and I’m struggling to get the striker pawn to follow the mouse as it should. As you can see on the video below, I managed to get it to follow the mouse except the movement is very shaky, like the object is jumping up and down as you move it.

[video]AirHockey 001 - YouTube

Below is the blueprint I created (based on this answer I found here):

Can anyone give me a hint of what I’m doing wrong? Thanks!

I suspect your line trace is colliding with the stricker itself, since you are using Visibility channel.

I suggest using WorldStatic instead, so your line trace will only collide with level BSP and meshes, and not dynamic things that come in the way.

Colliding with the striker makes sense, however I’m not sure I know how to make the change you’re suggesting: the trace channel options I have are only “Visibility” and “Camera”. How would I go about telling the trace to ignore the object I’m controlling?

Again, sorry if this sounds very obvious, I’m still getting my bearings on the engine.

Hmm, Epic deprecated the version that takes an actual CollisionChannel for some reason.

For a simple workaround, you can use the Camera channel. Make sure your striker pawn collision component(s) are set to Ignore the Camera channel, then it will not collide with it.

Alternatively, you can declare a new trace channel in your project settings, to achieve a similar result, without altering existing channels

In this case I would create a new trace channel named something like “StrikerControl”, with default response set to Ignore so nothing will collide with it by default. Then edit the collision preset “BlockAll” to enable Block for the StrikerControl trace channel. This way only objects that use the “BlockAll” profile (ie. pretty much only level geometry) will collide with your trace channel.

2 Likes

That worked flawlessly, it even got me collision between the striker and the side geometry for free – although I’m sure this “free” benefit will bite me in the behind later, but that’s a problem for another day.

Just for clarity, I used the later solution, creating a new trace channel.

Thank you very much!