[Resolved] applyLinearForce issues

I’m trying to launch an object with applyLinearForce. The following code crashes and says I attempted to call applyLinearForce (a nil value).

[lua]–Global touch listener for shooting

function shoot(event)

if event.phase == “ended” then

timer.performWithDelay ( 1, shootBall )
end

end

Runtime:addEventListener ( “touch”, shoot )
function shootBall()

local shooterball = shooterball.spawn()
shooterball.x = monkey.x
shooterball.y = monkey.y - 30
physics.addBody ( shooterball, {density=1.0, friction=0.0, bounce=0.8, radius = 20})
shooterball:applyLinearForce(1,1000,shooterball.x,shooterball.y)

end[/lua]

I can’t figure it out and I’m new to Corona, if anyone has quick thoughts that’d be awesome. Thanks [import]uid: 161435 topic_id: 28395 reply_id: 328395[/import]

Hey there,

You either want to use applyLinearImpulse or setLinearVelocity - or possibly applyForce. (You’ve just gotten a little muddled up with APIs, that’s all.)

Here’s a list; http://developer.coronalabs.com/content/bodies

Peach :slight_smile: [import]uid: 52491 topic_id: 28395 reply_id: 114662[/import]

Oh gosh, that’s hopelessly obvious now that I see it. Thanks! [import]uid: 161435 topic_id: 28395 reply_id: 114761[/import]

Hah, most errors are. Always happy to help!

Peach :slight_smile: [import]uid: 52491 topic_id: 28395 reply_id: 114907[/import]