my wasd is not linking with my camera, can anyone help?,My Camera is not syncing with my wasd movement, can anyone help?
Im currently making a FPS and i have already created my movement and look controls, but when i look in a certain direction and I press W, it moves me to another direction, I think my vector3 is linked to the world instead of my character, does anyone know how to solve this issue, this is my movement script:
 private void Awake()
 {
     //This is to get the information of our rigidbody and store it in the rb variable.
     rb = GetComponent<Rigidbody>();
 }
 private void Start()
 {
 }
 private void Update()
 {
     MovementInputs();
     Jumping();
 }
 private void FixedUpdate()
 {
     Movement();
 }
 private void MovementInputs()
 {
     //Those are for the inputs for the movement. This information is stored within the x and z variables.
     x = Input.GetAxisRaw("Horizontal");
     z = Input.GetAxisRaw("Vertical");
 }
 private void Movement()
 {
     //This is to create the movement and change our rigidbody's velocity based on the x and z which are multiplied by the walk speed.
     Vector3 movement = rb.velocity = new Vector3(x * walkSpeed, rb.velocity.y, z * walkSpeed);
     
 }
 private void Jumping()
 {
     //This is to get the input which is space and if it is pressed.
     if (Input.GetKeyDown(KeyCode.Space))
     {
         //If the space button is pressed, the velocity will change, the x and z will stay the same but the y will change based on the jump force applied.
         rb.velocity = new Vector3(x, jumpForce, z);
     }
 }
 
               } and this is my look controls script: private void Start() { playerBody = transform.parent.gameObject; //This is to lock and make the cursor invisible while playing the game. Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } private void Update() { CameraRotation(); } private void FixedUpdate() {
 }
 private void CameraRotation()
 {
     //This is to get the values of the axis from the Mouse X and Mouse Y which are shown in unity.
     Vector2 inputValues = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
     //This is for the up, down, left and right movement and to scale down the movement of the camera by smoothing and the sensitivity.
     inputValues = Vector2.Scale(inputValues, new Vector2(mouseSensitivity * mouseSmoothing, mouseSensitivity * mouseSmoothing));
     //This is to let the camera movement exist and to create a smoothing effect so the camera doesnt suddenly stop.
     smoothedVelocity.x = Mathf.Lerp(smoothedVelocity.x, inputValues.x, 1f / mouseSmoothing);
     smoothedVelocity.y = Mathf.Lerp(smoothedVelocity.y, inputValues.y, 1f / mouseSmoothing);
     currentlookingPos += smoothedVelocity;
     //Everything written in this bracket above is made for the calculations. Everything down now is for the actual movement.
     //wtf are quaterions?????
     transform.localRotation = Quaternion.AngleAxis(-currentlookingPos.y, Vector3.right);
     playerBody.transform.localRotation = Quaternion.AngleAxis(currentlookingPos.x, playerBody.transform.up);
     //This is to stop the full camera rotation infinite thingy, idk.
     currentlookingPos.y = Mathf.Clamp(currentlookingPos.y, -80f, 80f);
 }
 
               }
Thanks and take care everyone.
Your answer
 
             Follow this Question
Related Questions
Virtual camera odd behaviour. Scriptting noob questions 0 Answers
Unity 3D: Third person movement and mouse camera control 0 Answers
How to make FPS character jump in the direction my camera is facing? 0 Answers
WSAD Movement performs unwanted flipping of character 0 Answers
Script to make hand move in a punching motion not working? 0 Answers