iLMS知識社群歷程檔Login
Position: 黃國哲 > Unity
1090408 限制畫面的移動範圍
by 黃國哲 2020-04-08 21:06:23, Reply(0), Views(655)


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

 //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);
    }
Reply