Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Lookat mousePosition goes bananas

Discussion in 'Cinemachine' started by ngerbens, Jun 13, 2018.

  1. ngerbens

    ngerbens

    Joined:
    Nov 20, 2017
    Posts:
    12
    Hello!

    I'm having problems with a flying object which I follow/track with a vCam.
    When I fly around (with the code below attached), everything works fine, as soon as my mouse hits the outside of the screen the camera starts shaking and spinning out of a sudden. Does anyone know what's the matter? I'm not having this issue without the Cinemachine cam.
    1. Transform myT;
    2. public float movementSpeed;
    3. private Vector3 mousePos;
    4. private Vector3 aim;

    5. void Update(){

    6. mousePos = Input.mousePosition;
    7. mousePos += Camera.main.transform.forward * 100f;
    8. aim = Camera.main.ScreenToWorldPoint(mousePos);
    9. this.transform.LookAt(aim);
    10. myT.position += myT.forward * movementSpeed * Time.deltaTime * Input.GetAxis("Vertical-");

    11. }
     
    Last edited: Jun 19, 2018 at 7:51 PM
  2. ngerbens

    ngerbens

    Joined:
    Nov 20, 2017
    Posts:
    12
    Is there please someone who can help me? This is probably a common problem, since lots of people use pointing direction with a mouse, right?
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,204
    Can you show me the inspector for your virtual camera?