Update in the main loop to prevent hitching in entity movement