Rotate physics object

Hi 

I’d like to rotate a physics object after it collides with a wall. I have tryed timer.performWithDelay and preCollision, but its not working for me. Can anyone help please?

Here is the code I use for moving the physics object:

 local angle local function moveballoon() angle = math.rad(balloon.rotation) -- we need angle in radians local xComp = math.cos(angle) -- the x component local yComp = math.sin(angle) -- they y component local xS, yS balloon:setLinearVelocity(forceMag\*xComp, forceMag\*yComp) if turning and ( countRotation \< 90 ) then if ( math.abs( balloon.rotation - rudder.rotation ) \< 50 ) then rudder:rotate( direction ) countRotation = countRotation + rotateDelta else if ( direction \< 0 ) then rudder:rotate( balloon.rotation - rudder.rotation - 50 ) elseif ( direction \> 0 ) then rudder:rotate( balloon.rotation - rudder.rotation + 50 ) end end end balloon:applyAngularImpulse( -direction ) rudder.x = balloon.x rudder.y = balloon.y counter = counter + 1 end

Why do you want to rotate it manually?

i’d like to have simulate like a boat movement, where the player rotates the rudder and this causes the boat to turn. the space to move is limited with a wall and as the boat makes contact with the wall it should bounce of the wall on the same angle it hit it. 

but in reality the boat makes collision under X angle and then this angle goes to 0. the boat keeps hitting the wall under the same direction. probably it has something to do with my movement function, which I have included in my first post.

I also tryed this, but it didn’t work

timer.performWithDelay( 1, function() balloon:applyAngularImpulse( -angle ) end, 1)

Why do you want to rotate it manually?

i’d like to have simulate like a boat movement, where the player rotates the rudder and this causes the boat to turn. the space to move is limited with a wall and as the boat makes contact with the wall it should bounce of the wall on the same angle it hit it. 

but in reality the boat makes collision under X angle and then this angle goes to 0. the boat keeps hitting the wall under the same direction. probably it has something to do with my movement function, which I have included in my first post.

I also tryed this, but it didn’t work

timer.performWithDelay( 1, function() balloon:applyAngularImpulse( -angle ) end, 1)