Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Why do we need a new Vector3
So I understood this entire video with the exception of when we created a new Vector3 in the update method. We had it up top when we made it private. So why did we have to write it as new? Why didn't we have to do that with the floats but we did with the Vector3?
John Steer-FowlerCourses Plus Student 11,734 Points
I haven't got the code in front of me. But it sounds like up the top you are creating a new private variable and telling the program it is of the type 'Vector3'.
Vector3 isn't a variable, but a Struct. You have to create a new Vector3 rather than just assigning it. When we use the 'new' keyword before Vector3 we are creating a new copy of the Vector3 Struct.
Hope this helps explain it a little more.
It does thank you for your help.