when have version of code:
void update() { raycasthit hit = new raycasthit(); (int = 0; < input.touchcount; ++i) { if (input.gettouch(i).phase.equals(touchphase.ended)) { ray ray = camera.main.screenpointtoray(input.gettouch(i).position); if (physics.raycast(ray, out hit)) { hit.transform.gameobject.sendmessage("incrementcounter"); } } } }
it works fine , after one-click counter 1, after two-click counter 2 , it's ok.
i want use fixedupdate() instead of update() because in opinion update() slow. in words input reading slow - when want click 3 times fast, counter increment slow.
i tried use fixedupdate(), got bugs -> after one-click, counter equal 3 or two.
any ideas ?
that nature of how fixedupdate, update, , input interact. in situation, game loop this:
-- unity resets input.touchcount -- unity reads touch input, detects touch, , sets input.touchcount 1 -- unity determines physics simulation 3 frames behind, fires --- fixedupdate - code increments counter --- fixedupdate - code increments counter --- fixedupdate - code increments counter -- physics caught unity fires --- update
because ios devices locked vsync, have hard limit on how can process input (60fps - once every ~16ms). if have multiple fixedupdates running per update you're not hitting 60fps can start there -- if hitting 60fps , it's still slow have problems.
Comments
Post a Comment