Unity 5: 2D Platformer-Player Controls [3.2]
In this episode we will learn how to jump.
EXPLANATION of Transform;
Every object in a scene has a Transform. It's used to store and manipulate the POSITION, rotation and scale of the object
We needed position of our child object and from his position we made circle which checks are we grounded.
We used:
Transform groundPoint;
grounded = Physics2D.OverlapCircle(groundPoint.position,groundRadius,whatIsGround);
But we could also use GameObject instead of Transform:
GameObject groundPoint;
Then our grounded looks like this:
grounded = Physics2D.OverlapCircle(groundPoint.transform.position,groundRadius,whatIsGround);
Notice DIFFERENCE in "groundPoint.position" and "groundPoint.transform.position".
If we use GameObject we need to access transform of that object first to get position and type "groundPoint.transform.position".
Since every object in the scene has Transform and we need just position it is better to use directly Transform.
● Twitter: / dualcorestudio
● Instagram: / dualcorestudio
● Facebook: / dualcorestudio
--------------------------------------------------------------------------------------------
Official Website:
► https://www.dualcorestudio.com/
--------------------------------------------------------------------------------------------
Discord Crew:
❤️️ / discord
#unitytutorial #unity2d #tutorial #unity