设置固定变量范围

Value = Mathf.Clamp(value,0,5); //后面2个数值代表最小和最大

 

限制Player移动范围

        GetComponent<Rigidbody>().position = new Vector3

        (

            Mathf.Clamp (GetComponent<Rigidbody>().position.x, boundary.xMin, boundary.xMax),

            0.0f,

            Mathf.Clamp (GetComponent<Rigidbody>().position.z, boundary.zMin, boundary.zMax)

        );

posted @ 2017-07-24 22:22  sign尊者  阅读(0)  评论(0编辑  收藏  举报