2017-05-22 3 views
0

3D 플랫폼 게임에 대한 컨트롤을 만들었습니다. 어떻게 든 플레이어는 매우 천천히 떨어지고 있습니다.Unity Player가 매우 천천히 떨어졌습니다.

내 선수 개체에는 2 개의 구성 요소 인 기본 캡슐 충돌 장치와 기본 리지드 바디가 있습니다. 나는 아무것도 거기에서 변경을 didnt한다.

float movementSpeed = 8; 
float currentMovementSpeed; 
float speedSmoothTime = 0.1f; 
float turnSmoothTime = 0.2f; 
float jumpPower = 5; 
float airControlPercentage = 0.2f; 
float turnSmoothVelocity; 
float speedSmoothVelocity; 
bool isGrounded; 

    private void FixedUpdate() 
    { 
     isGrounded = GroundCheck(); // Is player grounded? 

     Vector2 inputDirection = (new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"))).normalized; 

     if (Input.GetButtonDown("Jump") && isGrounded) // Jump handling 
      Debug.Log("Player Jump"); 

     if (inputDirection != Vector2.zero) 
      transform.eulerAngles = Vector3.up * Mathf.SmoothDampAngle(transform.eulerAngles.y, Mathf.Atan2(inputDirection.x, inputDirection.y) * Mathf.Rad2Deg + cameraTransform.eulerAngles.y, ref turnSmoothVelocity, GetModifiedSmoothTime(turnSmoothTime)); // Rotate 

     currentMovementSpeed = Mathf.SmoothDamp(currentMovementSpeed, movementSpeed * inputDirection.magnitude, ref speedSmoothVelocity, GetModifiedSmoothTime(speedSmoothTime)); 

     playerRigid.velocity = transform.forward * currentMovementSpeed + Vector3.up * playerRigid.velocity.y * Time.deltaTime; // Move 

     currentMovementSpeed = (new Vector2(playerRigid.velocity.x, playerRigid.velocity.z)).magnitude; 
    } 

    private float GetModifiedSmoothTime(float smoothTime) // Limit the control while in air 
    { 
     if (isGrounded) 
      return smoothTime; 

     if (airControlPercentage == 0) 
      return float.MaxValue; 

     return smoothTime/airControlPercentage; 
    } 

    private bool GroundCheck() // Player is grounded? 
    { 
     if (true) 
      return true; 

     return false; 
    } 

누군가가 여기에 무엇을 알고 있는가 :

그래서 내 코드는 여기 하나는?

+0

'리짓 바디 (Rigidbody)'구성 요소에서 질량을 변경하려고 시도 했습니까? – Hristo

+0

또한 '강체'의 _drag_ 값을 살펴보십시오. 너무 높으면 움직임이 느려질 수 있습니다. – Kardux

답변

1

아마도 현재의 중력과 관련이 있습니다. 중력 값 edit -> project settings -> physics을 확인하십시오. 제 경우에는 -9,81입니다. 그것을 더 높은 가치로 바꾸고 무슨 일이 일어나는 지보십시오.

0

나는 마침내 그것을 얻었다. 그것을 해결하는 방법 :

을 코드 줄에서

playerRigid.velocity = transform.forward * currentMovementSpeed + Vector3.up * playerRigid.velocity.y * Time.deltaTime; 

이제 플레이어가 제대로 떨어지고

* Time.deltaTime 

을 가져 가라.

관련 문제