예제 #1
0
    // 지면 체크
    private void IsGround()
    {
        isGround = Physics.Raycast(transform.position, Vector3.down, capsuleCollider.bounds.extents.y + 0.2f); // Vector3.down >> 무조건 아래방향으로 (절대적인 값, 캡슐기준이 아닌!)
        // CapsuleCollider의 영역 >> bounds , extents >> bounds 크기의 절반 (extents.y >> y크기의 절반) // 0.1f는 약간의 여유 >> 계단이나 오르막길 등 오차 범위 때문.
        // Raycast로 해당 범위까지 레이저를 발사하여 무언가 물체가 닿았을 때, true 반환 아무것도 없으면 false 반환.

        theCrosshair.JumpingAnimation(!isGround);
    }
예제 #2
0
 // 지면 체크
 private void IsGround()
 {
     isGround = Physics.Raycast(transform.position, Vector3.down, capsuleCollider.bounds.extents.y + 0.1f);
     // 우선 transform은 up과 right 밖에 없는데 왜 -transform.up이 아니고 Vector3.down을 쓰는가?
     // 고정되게 아래를 향해야 하기 때문에 trasnform이 아닌 고정좌표인 Vector3을 사용
     // 캡슐 컬라이더 바운드는 플레이어의 영역이고, extents는 y의 절반 사이즈
     // 0.1을 더한 이유는 약간의 여유를 준 것이다. 계단이나 대각선, 여러 지형 때문에
     theCrosshair.JumpingAnimation(!isGround);
 }
예제 #3
0
 // 지면 체크
 private void IsGround()
 {
     isGround = Physics.Raycast(tr.position, Vector3.down, capsuleCollider.bounds.extents.y + 0.1f);
     theCrosshair.JumpingAnimation(!isGround);
 }
예제 #4
0
 private void IsGround()
 {
     // 만약 Vector3.down 이 아니라 -transform.up 을 쓰면 캐릭터가 뒤집어져 있을때 이상해짐
     isGround = Physics.Raycast(transform.position, Vector3.down, capsuleCollder.bounds.extents.y + 0.3f); //bounds.extents 는 절반 크기, 0.1f로 약간의 여유(경사같은곳에서 안닿았다고 착각할수 있음)
     theCrosshair.JumpingAnimation(!isGround);
 }
예제 #5
0
 //지면 체크
 private void IsGround()
 {
     isGround = Physics.Raycast(transform.position, Vector3.down, capsuleCollider.bounds.extents.y + 0.5f); //대각선이나 살짝 남는공간이 있을수있으므로 여유값0.5를 추가함.
     //theCrosshair.RunningAnimation(!isGround);
     theCrosshair.JumpingAnimation(!isGround);
 }
 // is player on Ground
 private void IsGround()
 {
     //extents : half , 0.1f : resolve stair bug
     isGround = Physics.Raycast(transform.position, Vector3.down, capsuleCollider.bounds.extents.y + 0.1f);
     theCrosshair.JumpingAnimation(!isGround);
 }
 private void IsGround()
 {
     //레이저를 쏘아서 감지
     isGround = Physics.Raycast(transform.position, Vector3.down, capsuleCollider.bounds.extents.y + 0.1f); //현재위치, 아래방향, 캡슐콜라이더.바운드.절반.y크기+약간의 여유오차
     theCrosshair.JumpingAnimation(!isGround);                                                              //점프할 때도 조준점 없애기 위해
 }