#Mouse movement
1 messages · Page 1 of 1 (latest)
void Update()
{
float mousex = Input.GetAxis("Mouse X") * MouseSens;
float mousey = Input.GetAxis("Mouse Y") * MouseSens;
playerBody.Rotate(Vector3.up * mousex);
}
This is what the code looks like now
Did you set mouseSens to something ?
Where ? Because the inspector will overwrite values from the code
public class MouseLook : MonoBehaviour
{
public float MouseSens = 100f;
public Transform playerBody;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float mousex = Input.GetAxis("Mouse X") * MouseSens;
float mousey = Input.GetAxis("Mouse Y") * MouseSens;
playerBody.Rotate(Vector3.up * mousex);
}
}
```This is the whole class
What is the value for mouse sense in the inspector ?
you mean this?
Ok do you get any errors in the console ?
Make sure to save your script or make sure the script is applied or restart unity
i will try restarting unity
didnt work
the script should be on the Main Camera right?
The script can be anywhere
As long as you dragged the correct transform into the playerbody
As long as it is on a gameObject it will run
Do i need to do anything with this?
In the last line why are you multiplying the mousex variable with a vector3.up
Yes you need to attach the script to a gameObject in the scene
because thats what brackeys told me to do
Do you have the script attached to the camera
yes
Do a Debug.Log(mousex); right before the rotate calk and see what pops in the console
And if your IDE is not configured go to #854851968446365696 to configure it
it goes negative when I move the mouse left, and goes positive when I move the mouse right
Can you show a screenshot of the player object, the cylinder
you mean the settings, or the object on the scene
the scene
Ok so that's completely symmetrical. How do you know it's not rotating?
oh
good point
Look at its transform. Does the rotation value change ?
I fixed it
What was the problem
wait nvm
not quite fixed
because the main camera is a child of the player
so it is locked to the player
so if the player rotates, the main camera should rotate too
Welk yes
I think I solved it
let me do some more testing
I have not
The camera rotates with the mouse
but
when i try moving the player around, it doesnt work
the player still faces the same direction
i think i see
I fixed that but now I have another problem
whenever I start my player is always flung off the plane
@supple tiger
Im not a teacher at your school. Ask in the channels and find someone yourslef 
I dont go to school but ok