Unity两点之间生成一条直线

 private void GetBetweenPoint(Transform target, Vector3 start,Vector3 end,float percent=1f)
    {
        Vector3 normal = (end - start).normalized;
        float distance = Vector3.Distance(start, end);
        
        target.position= normal * (distance * 0.5f) + start;
        target.GetChild(0).localScale = new Vector3(0.2f, distance / 2, 0.2f);//这里是将Unity中的Cylinder加父物体将X轴旋转90°
        target.LookAt(start);
    }

你可能感兴趣的:(Unity)