First person mouse input problem

The problem is this: I want to be able to manipulate the camera action with the default mouse movements but also be able to make mouse onclick actions to interact with objects. I am also trying to maintain the cursor locked to the center of view. I have enabled click events so I can now trigger events but then the cursor won’t lock to the center of view. So when trying to click on an object the player has to unnaturally motion away from the object, and when you get the cursor in position and click the object, you then have to hold a mouse button to start moving again. So to lock the view I add “Set input mode game and UI”. The overall action is correct, but now to move I have to hold a mouse button down. I don’t want that.

What I want is free movement without holding a mouse button, lock the cursor position to the center, and have click events to trigger actions. Any help is appreciated.

If I understand you correctly, you want to be able to move freely while having the cursor always locked to the center of your screen?

I think in this case you actually want to use a check trace, as it’ll be very useful in what you’re trying to implement here.

Thanks for the reply. I’m not able to find anything about check trace. Do you mean Line Trace? And would I replace the “Set input mode game and UI” with Line Trace? Is there a tutorial you can point me at for this? To be clear, I want to do the following:

  1. allow the player to look up/down/around freely with the mouse without holding a mouse button
  2. lock the cursor position at the center (crosshairs)
  3. be able to use onclick to interact with objects

Thanks

Yes, sorry, I meant a Line Trace by channel.

This would be ideal for your situation. So what you would want is to have a Line Trace when the ‘onclick’ event occurs. What this does is it shoots a trace from your character outward from the center of your screen and returns a large struct of information about anything the trace hits.

Here’s a link showing an implementation of it
[Unreal Engine 4 Tutorial - Simple Line Trace Weapon - YouTube][1]

But in your case you want to interact with objects. So instead of using the location of the hit actor, you’ll want different information from the hit result.

Here’s an example of using Line Trace by channel to interact with objects:

Here, you calculate the trace. It starts from your character to a given distance.

Here, you get the hit result information about whatever your trace hits. You can then pull that information into a return node.

And finally, in your character bp you have the event ‘onclick’ set up like this. You can then work out how you want to interact with the object now that you know you’re looking straight at one.

And here’s a link to another tutorial that uses this kind of line trace to interact with objects which I found super helpful when I first learned about it.
[A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums][5]

Forgive me but that seems like a complicated solution. I appreciate your efforts and I will review all the material you provided, but I feel like I’m looking for a simple way to reverse this particular action. Everything is working as I intend except I have to hold the mouse button to look around when I prefer I didn’t have to. This is what I have: press play, look around, see door, press w to move to door, click on door and door opens. That all works except the looking around requires holding the mouse button.

Again, really appreciate the help and I’ll try out this approach.

Update:
I followed this - YouTube which has really helped explain what you are suggesting. I think this is what I’m after. With this I should be able to use the line trace to interact with various blueprint actors.