How to have a ball bounce off a wall?

Ok I’m having a problem with physics. Ok the problem is everytime I have a ball roll towards a wall instead of it bouncing off it sticks and does not bounce. Here is the code for how I have my ball and wall physics set up

[code]local physics = require(“physics”)
require “ui”
physics.start()
local platform2 = display.newRect(400, 210, 10, 40)
platform2.name = “platform1”
physics.addBody(platform2, “static”,{bounce = 3, friction = 1})
localGroup:insert(platform2)

local ball = display.newImageRect(“smile.png”, 50,50)
ball.x = 100
ball.y = 200
physics.addBody(ball,{bounce = 0, friction = 1, density = 1 ,radius = 21})
ball.name = “ball”
ball.angularVelocity = 200
localGroup:insert(ball)
camera:addObject( ball )
camera:setFocus( ball )[/code]

What could be the problem? [import]uid: 17058 topic_id: 22283 reply_id: 322283[/import]

Try taking your friction down to .10 anything above 1 seems to make things stick. Also add some bounce to the ball. [import]uid: 80890 topic_id: 22283 reply_id: 88763[/import]

again still nothing I have it set like this now

[code]
local ball = display.newImageRect(“smile.png”, 50,50)
ball.x = 100
ball.y = 200
physics.addBody(ball,{bounce = 0.7, friction = 0, density = 1 ,radius = 21, isSensor = false})
ball.name = “ball”
ball.angularVelocity = 200
ball.isBullet = true
localGroup:insert(ball)
camera:addObject( ball )
camera:setFocus( ball )

local platform2 = display.newRect(400, 200, 10, 40)
platform2.name = “platform1”
physics.addBody(platform2, “static”,{bounce = 3, friction = 0 ,density = 1, isSensor = false})
localGroup:insert(platform2) [/code] [import]uid: 17058 topic_id: 22283 reply_id: 88768[/import]

I just tested this and the ball bounces off the platform and into orbit!

[lua]-- include Corona’s “physics” library
local physics = require “physics”
physics.start(); physics.pause()

physics.setScale( 60 )
physics.setGravity( 0,0.5 )

local localGroup = self.view

local ball = display.newImageRect(“smile.png”, 50,50)
ball.x = 100
ball.y = 200
physics.addBody(ball,{bounce = 0.7, friction = 0, density = 1 ,radius = 21, isSensor = false})
ball.name = “ball”
ball.angularVelocity = 200
ball.isBullet = true
localGroup:insert(ball)
–camera:addObject( ball )
–camera:setFocus( ball )

local platform2 = display.newRect(100, 300, 10, 40)
platform2.name = “platform1”
physics.addBody(platform2, “static”,{bounce = 3, friction = 0 ,density = 1, isSensor = false})
localGroup:insert(platform2) [/lua] [import]uid: 10389 topic_id: 22283 reply_id: 88772[/import]

@waulok I forgot to mention the ball moves like this

local function move () ball.x = ball.x + 4 end Runtime:addEventlListener("enterframe", move)

So why is it sticking? [import]uid: 17058 topic_id: 22283 reply_id: 88777[/import]

Probably because you are moving it yourself instead of letting gravity/physics do it. Maybe try a transition instead of x+4. [import]uid: 10389 topic_id: 22283 reply_id: 88779[/import]

Better still:

[lua] ball:applyForce( 500, 00, ball.x, ball.y )[/lua] [import]uid: 10389 topic_id: 22283 reply_id: 88781[/import]