Unity3d - 什么是linecast hit.normal?

问题描述 投票:0回答:1

我想知道什么是 hit.normal 这是一个简单的检查字符坡度限制的方法,我唯一想知道的是,我想知道的是。hit.normal 什么事?


private void check_slope_limit() {
    // Var
    var hit_angle = 0f;

    // Raycast
    RaycastHit hit;

    // Line of direction: if hit ground layer
    if (
        Physics.Linecast(transform.position + Vector3.up, transform.position + direction.normalized, out hit, ground_layer)
    ){
        hit_angle = Vector3.Angle(Vector3.up, hit.normal);

        var target_point = hit.point + direction.normalized;

        Debug.DrawLine(transform.position + Vector3.up, transform.position + direction.normalized, Color.yellow);

        if (
            hit_angle > slope_limit 
            &&
            Physics.Linecast(transform.position + Vector3.up, target_point, out hit, ground_layer)
        ){
            if (hit_angle > slope_limit){
                move = false;
                return;
            }
        }
    }
    move = true;
}

Image


我真的很讨厌做一些不了解的事情

unity3d line physics raycasting ray
1个回答
1
投票

是这样的 正常 的表面在击中点。

diagram of hit normal

© www.soinside.com 2019 - 2024. All rights reserved.