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

SmoothFollow Script editing - beginners

Discussion in 'Scripting' started by Arcvelox, Jan 4, 2014.

  1. Arcvelox

    Arcvelox

    Joined:
    Jan 4, 2014
    Posts:
    1
    Hello everyone, this is my first post on the unity forums! :)

    How would I go upon changing the SmoothFollow script, that came with Unity by default, so that the camera angle doesn't automatically rotate to the back of the target. But rather just stay at the angle it is?
     
  2. MDragon

    MDragon

    Joined:
    Dec 26, 2013
    Posts:
    329
    This may be an overly crude or simplistic method, but simply comment out the following line:
    Code (csharp):
    1. transform.LookAt (target);
    (line 56)

    I say overly crude/simplistic because some of that math may not be unneccessary. However, after going through the code, it seem like that all the math is necessary for the "smooth" follow effect, including the math with the angles.

    Essentially, I think that's all you need to do and don't have to worry about the math :D By the way, if you're curious how I (primarily) found out what code to take out/change to stop the rotation, all I did was see what actually affected the camera itself directly, which was three things:
    1) The three transform.positions (lines 49, 50, 53)
    2) The line above, line 56

    Transform.position doesn't ever actually change the rotation- it does as it implies: It merely changes the position of the camera itself. That leaves number 2.