Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRanvir Sahota
9,844 PointsTransform.LookAt()
Why use transform.LookAt()? I commented out the code once to see what happens with the method but nothing happened. So I thought maybe I'll understand why it's been used later on, but no. I have not seen it have any effect. So I guess in this instance we will always look at the target object when we are simply rotating around but when would situations arise that we aren't looking at the target object and the LookAt method is required to change the game objects direction?
1 Answer
Alan Mattan贸
Courses Plus Student 12,188 PointsWhen you are rotating the camera around the target, you are moving the camera. The camera at the start can have a different orientation angle and not properly facing the target. The target can be moving or you maybe you need a curve path to move the camera instead of rotating around. You can also include an extra up-down oscillation, as it done later, using the sin equation. At this point, is useful to finally rotate the direction of the camera directly facing the target, to be sure that is oriented properly at the final stage of the update. This kind of animation is also more code friendly.