Hi,
I want to know how I can move an object along its z axis when the mouse is moved up or down using blueprints.
I hope someone can help.
Hi,
I want to know how I can move an object along its z axis when the mouse is moved up or down using blueprints.
I hope someone can help.
Hi man,
you can “set an actor location” or “add a offset location” to any actor with these two nodes.
You have to feed in a vector, to say to your actor the direction and amount of space to travel.
Setting an actor to 1,0,0, will place the actor to x1,y,0,z0
Adding actor location 1,0,0 will place the actor always 1x forward
Beware that exist Local coordinates and world coordinates, and so a world X direction and an actor X direction.
You can get the mouse position at every tick of the game using get mouse position Get Mouse Position | Unreal Engine 5.2 Documentation
you have to plug in a player controller to get the x and y
these two value are based on the screensize of your game , and may vary if you change the size of the screen or device.
A simple example is creating an actor, and drag it to the level,
in his tick event make him “set location” to the ( mousex , 0 , 0 )
Hit play , fly until you can see the 0,0,0 of the world, then move the mouse in the upper left of screen
++++ example you can start saving in a variable the x,y, of the mouse (old_mouse)
then in every next tick, you can do old_mouse - new x,y and get only the value of the movement of the mouse
Then set again the new x,y as old_mouse
this way you will be able to “add” or “set” the location of your actor with only the difference of the mouse positions.
Hi, thank you for the explanation!.
I have got 2 more questions:
I am detecting the difference of the mouse y position with the script below that I have placed in my level blueprint.
This script only works in the level blueprint. If I place it into the “thirpersoncharacter” blueprint it doesnt calculate the differene of newMouseY and oldMouseyY.
Can you tell me why that is the case?
What is the difference between the node “GetMousePositionOnViewport” and the node “GetMousePosition” with target Player Controller?
Hi man,
as you can see when you have the game in window is more clear but is messy anyway
the mouse viewport is referring to the actual game window,
( the mouse is invisible but is almost in the upper left corner of the game window )
but for my mac the mouse is still far far away from upper left
thats a little mess,
here an answert about your specific question https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/1481403-get-mouse-position-on-viewport
here a doc about all the stuff relative to the viewport Viewport | Unreal Engine 5.2 Documentation
I have made this test with a a empty actor, works fine, i dont know why you cant access these values,
are you sure the event is fired?