I am trying to make the camera move from side to side with the mouse movement alone. Right now, in order to move the camera with the mouse, I have to click a key in order to do it. I just want the mouse movement to rotate the camera and I believe I have most of the code, but I’m not sure how to get the player camera reference to work. Here is the code I set up for the mouse input so far
What class is this Event Tick code in?
It’s in my level blueprint.
Yeah you want to work directly with the character or controller for this.
Camera is a character component. From character you would use Get Controller
. Then drag the camera from My Blueprint tab into the graph.
So i don’t make it a variable? Though that didn’t work anyway since it won’t connect.
I only have a camera actor in the world and the follow camera in the player controller. I don’t have a blueprint for it.
Just code it in the controller class then.
This is what the tick node looks like now but the camera still doesn’t move unless I hold any of the mouse buttons down. I am just lost lol, and these video tutorials are not helping in the slightest.
Use Set Control Rotation
your maths is a bit wrong too, you may want to GetHitResultUnderCursor and FindLookAtRotation between the Character/HitResult. you may want to RInterp it too
The two “camera input” nodes are actually what control my mouse movements right now. I have another set of nodes restricting the movement to only the “x” axis for horizontal rotation only (though that likely isn’t relevant) but I am wondering if there is a specific node or set of nodes that is the reason my cursor will only move the camera if I am holding down any of the mouse buttons. That is strange
This image is all the code I have pertaining to the mouse inputs, with the exception of the nodes that involve unrelated UI elements:
are you sure you are getting exact mouse pos in 2d? make sure the values you get are between -1 and 1.
And then you can use those values to apply rotation like simply multiplying the value by 180 - this way you get values between -180 to 180 ig and then just plug in that value to the Z axis or any axis you’d like
I have no idea. I am still new to coding and don’t know exactly what all the nodes do yet. Maybe I didn’t properly articulate what I am looking to do.
When starting the game, instead of having to click into the window to allow the mouse to move the camera, I just want to automatically be able to move the camera with the mouse when the game starts.
The camera movement itself is exactly what I want it to be. My specific problem is just allowing the cursor itself to move the camera at the start of the game.
There’s a node exactly for that, in your current blueprint class on Event BeginPlay node just connect ‘Set Show Mouse Cursor’ node and check the boolean and then it should work!
I already have that checked off. The problem is that when I start the game, the cursor doesn’t control the camera unless I have a mouse button held down.
I want the cursor to control the camera without having to click or do anything. I know it’s gonna be something simple and stupid which is usually the case since with me in coding so far, but I just can’t figure out what to do. And none of the tutorials I watched are giving the result that I want specifically.