# Physics objects going past walls.

So I made walls that cover the edges of the screen, and the physics ellipses will bounce off of the walls with no problem. However, when the balls are going too fast (due to the linear velocity) the balls fly outside of the screen and past the walls that I left as default, and not static or kinematic. I have always had trouble with this in my game and was wondering if I could cap the linear velocity or approach this situation a different way.
Thanks guys!

@YoloSwag Look under physics for physics.continuous. You can also limit the velocity.

How would I limit the velocity? The physics.continuous did fix the issue though, thanks.

@YoloSwag Here’s an example of limiting one of the falling objects from going faster then -100. Both objects would fall at the same speed if I wasn’t limiting the one on the left. I display their downward velocities. You could do the same with the x velocity if it was moving left or right.

``````
function setup()
b=physics.body(CIRCLE,5)
b.x=WIDTH/2
b.y=HEIGHT
c=physics.body(CIRCLE,5)
c.x=WIDTH/2+20
c.y=HEIGHT
end

function draw()
background(40, 40, 50)
fill(255)
ellipse(b.x,b.y,10)
ellipse(c.x,c.y,10)
v=b.linearVelocity  -- get linear velocity
if v.y<-100 then    -- falling faster than -100
b.linearVelocity=vec2(v.x,-100) -- limit y velocity to -100
end
text("b velocity  "..b.linearVelocity.y,WIDTH/2,HEIGHT-50)
text("c velocity  "..c.linearVelocity.y,WIDTH/2,HEIGHT-100)
end

``````