Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question how do i stop camera moving

Discussion in 'Editor & General Support' started by lz7cjc, Jan 27, 2022.

  1. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    534
    Hi
    I am using in one of my scripts and this works fine to move the camera
    Code (CSharp):
    1.  
    2. Player.MovePosition(transform.position + transform.forward * speed * Time.deltaTime);
    3.  
    I then need to deal with a usecase where they don't stop moving before jumping to another area of my scene. So I need to stop the camera in a different script, when it is called. I have tried this

    Code (CSharp):
    1.         player.transform.position = cameratarget.transform.position;
    2.         player.transform.SetParent(cameratarget.transform);
    3.         player.MovePosition(transform.position + transform.forward * 0 * Time.deltaTime);
    but the camera keeps moving

    any ideas?
    thanks