Search Unity

LookAt Cursor? C#?

Discussion in 'Scripting' started by JeffHardddyyy, Dec 26, 2016.

  1. JeffHardddyyy

    JeffHardddyyy

    Joined:
    Dec 6, 2015
    Posts:
    23
    Hi So I've looked at about 5-10 "LookAtCursor" Scripts, and none seem to work,

    I was wondering, if anyone knows if there is any tutorials that are decent today and works for C#


    Or at least have a idea on how to get started ?
     
  2. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    LookAtCursor? You mean mouselook, where the camera rotates if you move your mouse?
     
  3. JeffHardddyyy

    JeffHardddyyy

    Joined:
    Dec 6, 2015
    Posts:
    23
    Yes sir!
     
  4. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    Well you can get the movement of the mouse with Input.GetAxisRaw("Mouse X"/"Mouse Y") then you can store this value in a Vector3 like so => currentRotation += new Vector3(-mouseY, mouseX, 0)
    then you can apply this rotation with transform.rotation.eulerAngles = currentRotation
     
  5. JeffHardddyyy

    JeffHardddyyy

    Joined:
    Dec 6, 2015
    Posts:
    23

    I understood all of that, except for the "Store value in Vector 3" Is currentRotation a float?
     
  6. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    currentrotation is a vector3
     
  7. JeffHardddyyy

    JeffHardddyyy

    Joined:
    Dec 6, 2015
    Posts:
    23

    So do I make that a namespace?
     
  8. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    Did you learn C# before attemting unity?
     
  9. JeffHardddyyy

    JeffHardddyyy

    Joined:
    Dec 6, 2015
    Posts:
    23
    No sir, I tried learning JavaScript via sololearn, then when I got Unity, I didn't understand their way of JavaScript, when looking up tutorials it came to my conclusion that they used C# more than JavaScript. And this was less than a year ago, So I've been trying to learn a lot, But not too much because I forget things REALLY easily, So I try not to overwhelm myself..
     
  10. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,532
  11. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    It's not really js
    No, start here:
    learncs.org
     
    MV10 likes this.