1090408 限制畫面的移動範圍
by 黃國哲 2020-04-08 21:06:23, 回應(0), 人氣(567)
以速度為例
//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);
}
回應