コード例 #1
0
 private void clearGround()
 {
     ground = null;
 }
コード例 #2
0
 private void clearGround()
 {
     ground = null;
 }
コード例 #3
0
        public void Probe()
        {
            clearGround();

            float probeHeight = controller.Position.y + ( controller.Radius * 2 ) + ( Mathf.Abs(controller.Velocity.y) * Time.deltaTime );
            Vector3 o = new Vector3( controller.Position.x, probeHeight, controller.Position.z );

            DebugDraw.DrawMarker( o, 0.25f, Color.green, 0, false );

            float smallerRadius = controller.Radius * 0.8f;

            RaycastHit hit;
            if( Physics.SphereCast( o, smallerRadius, -controller.Up, out hit, Mathf.Infinity, environmentLayer ) )
            {
                Vector3 p = MathUtils.MoveTowards( hit.point, controller.Position, controller.Radius );

                ground = new Ground( hit.point, p, hit.normal, hit.distance, hit.collider.gameObject );
                DebugDraw.DrawMarker( hit.point, 0.25f, Color.red, 0, false );
                DebugDraw.DrawMarker( p, 0.25f, Color.blue, 0, false );
            }
        }