Part seven in the development of our MMO-style controller. The original specification with contents and an overview can be found in this post. Quite a lot of posts now, isn’t it!?
Now we’re moving back to our final feature in the MMO-style controller, using the mouse to move our camera around, and control the character’s orientation. All those functions we wrote earlier are really going to help us here!
Left and right click actions
Firstly, we’re going to need to set up some logic with for the when the user presses the right and left click buttons on their mouse.
First we’ll need some functions to control interaction with the UI and game world:
These two functions change how we interact with the game world. We’ll use these support the mouse drag and rotate feature. When toggled off, the mouse disappears and we cannot interact with the UI. We’ll also disable mouse related events for the game. If we set UI control back on again, we’ll keep the mouse to the game window, and re-enable the things that were turned off.
Now we can add these into the left click action event:
When we press left click, we set a LeftMousePressed boolean to true, and we turn off the UI Control.
When left click is released again, we’ll re-enable UI control if right click is not also pressed. If RightMousePressed is true, we do nothing.
The final node in the released chain is a little bit of polish. Once we’ve done rotating the camera using left click and drag, the next time we move, we want the character to move in the direction the camera is facing. We do this by updating the rotation of MyPlayerController.
Hoe about the right click action event?
This almost the same as left click, but we don’t add that final function to the released sequence. The reason for this, is that right click and drag will update rotation anyway, so we don’t need to do this twice.
Camera rotation control
The vital and missing information left out from the initial upload!
There are two functions to create which are used to control the camera:
This will allow us to control the position of the camera.
Left click and drag camera
We’ve done a lot of the hard work for this earlier in setting up our blueprints. EDIT: Looks like I missed adding this information when I first uploaded. It is now included in the section above.
Since we have the axes Turn and LookUp already set up, it is a simple task to only make these events do something is LeftMousePressed is true.
If it is true – that is the player is holding left mouse down and moving the camera – we simply rotate the camera, using our two functions CameraTurn and CameraLookUp.
Almost too easy!
Right click and drag camera
What does holding right click and drag do? We rotate the camera and the player controller. Easy.
Very similar to left click, except we also need to RotateCharacterToCamera, and add pitch input to the player controller. What could be simpler!?
All our hard work earlier really paid off in this section. Those re-usable functions really are worth their weight in gold, and make the blueprints a lot more readable.
Perhaps something stupid but in the Left click and drag camera you have a function Rotate Camera LookUp, that is missing (or I have looked over it) on the previous tutorials [>.<']
For the rest good tutorial! 🙂
LikeLike
Let me have a look, maybe I’ve missed something!
LikeLike
that even this missing lookup function
LikeLike
I’ve added the two missing functions now! Sorry about that
LikeLike
The missing functions should have been added now
LikeLike
yes thank you for that, but the image was too small not to understand the.
You can fix?
LikeLike
They should now link to the full size image!
LikeLike
I’m from Brazil and I am a student in school saga school of art thank you very much your tutorial was more than great was perfect
LikeLike
Good luck with your studies, make a video when you finish your game so I can see what it is like!
LikeLike
the fuction RotateCameraTurn (second one missed) seam it was just writed in Character Rotation section.
in any case great work.
LikeLike
guy was very good even parabens and thank you was the way I wanted.
good ‘ll let my facebook
http://www.facebook.com/israel.messias.58?ref=bookmarks
If you want to track when to launch .
I will thank you again and I will indicate this page
thank you so much
LikeLike
Is all this added to the PlayerController and also the last bit with Left and right Drag, it complains having two of the same input functions (Turn and Look Up) in the same blueprint? Also what are the values of Input Pitch Scale and Input Yaw Scale?
LikeLike
I can’t seem to find where “Add Pitch Input” was ever defined in relation to the the last image. Can I be referred to where that is, please? Other than that, lots of help!
LikeLike