issue#661 update state before values are cleared

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