How could i rotate an object with middle mouse button?

As the title says, i want to rotate an object while the middle mouse button is held, i assume you would need to calculate vectors ect.Any help would be appreciated.

You should start with an Event Tick node. Connect it to a Gate node. The Gate node will allow execution to pass through while open (or while the button is pressed), and deny execution when closed (button released).

Create a Middle Mouse Button event. Drag off of the Pressed output, and connect it to the Gateā€™s Open input. Drag off the Released output, and connect it to the Gateā€™s Close input.

Drag off of the Gateā€™s Exit output, and create an Add Actor Local Rotation node. For the Delta Rotation input, drag off of it and make a Make Rot node. Enter the amount you want your actor to rotate per-tick. Pitch is rotating about the Y axis, Yaw is rotating about the Z axis, and Roll is rotating about the X axis.

Just a note: This blueprint relies on the Event Tick node, which means that the rotation of your actor will be dependent on the frame rate of your game. To remedy this, you can multiply your rotation by the Delta Seconds output of the Event Tick node. This will scale the amount of rotation per frame with the frame rate.

I appreciate the help, but this does not allow me to actually control the rotation with the mouse movement, it just rotates it on itā€™s own, is there anyway i can hook up the mouses xyz movements into the make rot?

Well, a mouse only moves in X and Y axis, so how would you want it to rotate if you moved the mouse left and right vs. up and down?

when i hold down middle mouse and move my mouse left, i want the object to rotate left, right rotate right up up ect ect

If itā€™s a 3D perspective game, then itā€™s as simple as implementing the FPS Templateā€™s mouse controls on the object, but checking for MMB being pressed first.

This would use the two events InputAxis Turn connected to Add Yaw Input and InputAxis LookUp connected to Add Pitch Input.

Or if you could use Get World Rotation, then add to it by creating a rotation (Make Rot) with your two InputAxis values (LookUp = Pitch, Turn = Yaw, leave roll at 0) and using Combine Rotators (Combining ā€˜Get World Rotationā€™ and our new ā€˜Make Rotā€™). Then use Set World Rotation to apply the new rotation to your object.

(I havenā€™t tested this. Once I get home Iā€™ll see if I can make it work and give you some screenshots)

I also assumed this but even if i set up a true false variable waiting for middle mouse button to be pressed, its not letting me turn when InputAxis Turn is even waiting to be called.

Here, try this out and see if itā€™s what youā€™re trying to do:

1 Like

Unfortinatly that does not allow my character to rotate at all while that is in the blueprint.
I should also mention that it is actually working when i hold middle mouse button, the object is moving as desired however my player cannot rotate at all

Oh, I didnā€™t know you were trying to retain the original controls as well.

How about this?

Thatā€™s odd, Iā€™m able to rotate the actor left/right and up/down on my end.

In your screenshot, your Get Actor Rotation node is assigned to self, but your Add Controller Pitch Input and Add Controller Yaw Input nodes are assigned Get Player Character at index 0. Is that intentional?

Oh I see. Well it is probably the same value anyway, but you can try to use a reference to self. Right click anywhere in your blueprint and type ā€˜selfā€™ to get a reference.

Just so weā€™re clear, youā€™re saying that when you move your mouse up and down, nothing is happening?

So close i can taste it, the only problem now is that it only rotates left and right and not up and down, i have to say i really appreciate all this help and quick replies :slight_smile:

I got a compile error saying the target pin of the controller inputs needed to be added so i tried that, i also tried player pawn, still no change

Correct sir

Fixed it!, i tweaked the make rot inputs around a little and came up with this

That works fine now, thanks for all your help youā€™re a legend, while i have you here, and dont feel the need to make the blueprint just to show me but how would i go about adjusting speed or rotation ( im guessing its some sort of look sensitivity) and inverting the ā€œleft and rightā€ movement.

Hah, that timing

The only thing I can think of is that perhaps your character needs to use Roll instead of Pitch. I donā€™t know how you have your actor setup for Controller Input, but you can try replacing Add Controller Pitch Input with Add Controller Roll Input. Also change the InputAxis LookUp node to output Axis Value to Make Rot nodeā€™s Roll input, instead of Pitch.

If that doesnā€™t work, Iā€™m afraid Iā€™m all out of ideas without being able to open up your project :frowning:

Oh fantastic, you came to the same conclusion that I did. Great job.

You can adjust the speed of the rotation by multiplying the Input Axis nodesā€™ Axis Value output by a new float variable (maybe named ā€˜Rotation Speedā€™ or something) before connecting it to Make Rot.

To invert the direction of left/right rotation, multiply by a negative number instead. (Just for Yaw though).

Be sure to set your new variable somewhere, or give it a default value.

Coudnā€™t find out how to contact you, there is no private message on this, i might need some of your expertise again whenever youā€™re free.

Basically this problem is happening ā€œbeforeā€ the rotate stuff, its picking up and dropping objects, i had it working fine and simple, but now i am trying to make it so i cannot pickup more than one object at a time, i have been toiling with it for ages but no luck at the moment it is picking up the object and refusing to drop it, but atleast it wont let me pick up a second object, hope you can help :slight_smile: