LoginSignup
1
1

More than 5 years have passed since last update.

CharacterController.IsGroundedの判定を楽に誤魔化す

Posted at

ゲーム作ってる最中、坂を移動するときになんかおかしくなるな~と思って調べていたらCharacterController.IsGroundedの判定の精度がちょっとイマイチな事を知ったので、誤魔化した方法を書いていきます。

自分がやった方法としてはこんな感じです

PlayerController.cs
using UnityEngine;

public class PlayerController : MonoBehaviour {

CharacterController  charactercontroller;
float groundtime;
bool isgrounded;
void Start(){ charactercontroller = GetComponent<CharacterController>();}
void Update()
{
   if (charactercontroller.isGrounded)
        {

            groundtime = 0.0f;
            isgrounded = true;
        }
        else
        {
            groundtime += Time.deltaTime;
            if (groundtime >= 0.5f)
            { isgrounded = false; }
        }  
}
}

CharactercontrollerのisGroundedがもし0.5秒以上falseならisgroundedをfalseにする...的な感じにしてみました。
【Unity】CharacterController IsGrounded の判定を改善する

ぐぐったらこの方の記事が出てきたんですが、Raycast飛ばすのも重そうだしUniRXもわからないしなあ..って思ったので考えてみました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1