Properly lock physics input and output state in script engine