Unity Platform 03 Jump / Wall friction / Set animation
===
20200807
###### tags: `platform`
## List
1. [Ground Check](#GC)
2. [Double Jump](#DJ)
3. [Side Wall friction](#SW)
4. [Set Anim](#SA)
## Content
### Ground Check<a id="GC"/>
Way to Ground_Check use technic called <i>**grounding**</i><br>Some Empty Object is set in player's below, calculate overlap with other objs.<br>If it overlap Ground Objs, Player is grounded.
```csharp=
bool isGrounded
LayerMask WhatIsGround;
float groundCheckRadius;
Transform groundCheck;
private void CheckSurroundings()
{
isGrounded = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, WhatIsGround);
}
```
### Double Jump<a id="DJ"/>
Double Jump is most game's control technic.<br>Make it with some flags.
```csharp=
int amountOfJumps = 2;
int amountOfJumpsLeft = amountOfJumps;
private void CheckIfJump()
{
if (isGrounded && rb2D.velocity.y <= 0)
amountOfJumpsLeft = amountOfJumps;
if (amountOfJumpsLeft <= 0)
canJump = false;
else
canJump = true;
}
protected void Jump()
{
rb2D.velocity = new Vector2(rb2D.velocity.x, jumpForce);
amountOfJumpsLeft--;
}
```
### Side Wall friction<a id="SW"/>
Wall friction is set with material component. 0 friction setting in wall.<br>
Ref this : 19:00 ~ [youtube lecture](https://www.youtube.com/watch?v=MReoItM8BoI)
### Set Anim <a id="SA"/>
Set Animation with animator & animation windows.<br>Animation is set duration or attribute of `.anim`.<br>Animator control relation of anims.<br>
Ref this : 15:40 ~ [youtube lecture](https://www.youtube.com/watch?v=MReoItM8BoI)