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 trialYassin Sassi
3,571 PointsWhy or when exactly gets the hopping animation triggered?
As far as I understood we just change the property Speed. Is the animation inside of the player prefab and gets triggered when the Speed property has a certain value?
My second question: Why can we just use the arrow keys to move our frog? Don't they need to be initialized as input keys inside of the code? Or are they initialized in the parent (MonoBehaviour) class?
1 Answer
Justin Horner
Treehouse Guest TeacherHello Yassin,
Great questions!
To your first question, the hop animation and its trigger are a part of the Player prefab. If you open the PlayerController uner the Animations folder, you can see a diagram of the animations and view their trigger conditions.
Here's a screenshot that shows the Idle to Hop trigger where the animation will happen when the speed is greater than 0.5. If I change this value to any value over what is used in the course, 10 for example, the frog will no longer jump when I use the arrow keys because we're setting the speed to 3.
And to your last question, every Unity project has default input axes. You can view these in Unity by going to Edit -> Project Settings -> Input. By default, Horizontal and Vertical axes are mapped to w, a, s, d and the arrow keys. You can find more information about input defaults here.
I hope this helps.
Yassin Sassi
3,571 PointsYassin Sassi
3,571 PointsThanks for the thorough answer! That clears it up quite well!
Justin Horner
Treehouse Guest TeacherJustin Horner
Treehouse Guest TeacherYou're welcome!