x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.12
Tags:
more ▼

asked Jul 05 '16 at 02:20 AM in Blueprint Scripting

avatar image

GaLew
41 2 8 13

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jul 05 '16 at 02:41 AM

avatar image

Mookaroni
569 21 9 35

avatar image GaLew Jul 05 '16 at 11:44 PM

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

avatar image Mookaroni Jul 06 '16 at 12:16 AM

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 https://www.youtube.com/watch?v=DTNO4kULts4

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. alt text

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

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. alt text

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. https://wiki.unrealengine.com/Pick_Up_Physics_Object_Tutorial

temp2.png (293.8 kB)
temp3.png (518.4 kB)
temp4.png (156.3 kB)
avatar image GaLew Jul 07 '16 at 01:06 AM

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 https://www.youtube.com/watch?v=WwfsWr4A894 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.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question