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