Unity3d-线播播放是什么。正常

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

请原谅我的英语不好。但我想了解线播的效果如何。这是检查角色坡度限制的简单方法,我唯一想知道的是击中。正常情况是什么?


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个回答
0
投票

是到达点表面的normal

diagram of hit normal

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