issue#661 update state before values are cleared

this prevent loosing state values related to physics bodys
and inputs before `state.update` is called.