iLMS知識社群歷程檔登入
位置: 黃國哲 > Unity
1090408 限制畫面的移動範圍
by 黃國哲 2020-04-08 21:06:23, 回應(0), 人氣(481)


限制參數的語法如下:
以速度為例

 //constraint
    if(rigid2D.velocity.x>speed_x_constraint)
    {
    rigid2D.velocity= new Vector2 (speed_x_constraint.rigid2D.velocity.y);
    }
     if(rigid2D.velocity.x< -speed_x_constraint)
    {
    rigid2D.velocity= new Vector2 (speed_x_constraint.rigid2D.velocity.y);
    }
回應