Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

First person camera restricted movement

Discussion in 'Scripting' started by joelgoty, Sep 24, 2016.

  1. joelgoty

    joelgoty

    Joined:
    Sep 24, 2016
    Posts:
    2
    Alright so I'm really new to programming and am trying to make an fps prototype. I used some code for the mouse to player camera. When i try to play the game the camera only moves around a diagonal axis, no matter how i move my mouse.
    no errors or warnings are showing up, any help is appreciated.
    View attachment 203185
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,840
    OK, first, welcome to the Unity community!

    Next: you don't need to paste images of your code (and please don't). Use code tags instead.

    Third: you are abusing Lerp. Please stop. Any time you're passing the current value as the first parameter of Lerp, you should probably be using MoveTowards instead.

    Finally, the reason your camera is moving diagonally is probably that you're using md.x in both line 23 and line 24. I suspect you meant to use md.y in line 24.

    Cheers!
    - Joe
     
  3. joelgoty

    joelgoty

    Joined:
    Sep 24, 2016
    Posts:
    2
    Thanks for the tip. Like I stated I know close to nothing and this is big help also i have no idea how i missed that
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,840
    We've all done things like that from time to time. Sometimes you just need a fresh pair of eyes on it. :)