Author Topic: LagPosition  (Read 5651 times)

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
LagPosition
« on: July 03, 2012, 02:13:46 PM »
Just bought NGUI!

Looking at the code for LagPosition, I'm confused as to why you place your Lerp method in a CoRoutine rather than in LateUpdate when you don't want elapsed time to be included.

I'm also not clear on the point of a CoRoutine that doesn't include a Yield statement.

Finally, I can see that placing the Lerp function in LateUpdate causes it to be continuously executed each frame, but placing it in a coroutine would seem to only run once as it would complete when the Lerp method completed the first time...

Obviously I'm confused on something rather basic but I've searched for hours on the subject without joy. :-(

Thanks for the clarification.
« Last Edit: July 03, 2012, 02:25:48 PM by Maxii »
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: LagPosition
« Reply #1 on: July 03, 2012, 02:42:31 PM »
LagPosition is just an example script. As I recall, UpdateManager treats late updates and coroutines differently, that's all. It's also not a real co-routine. It simply means it runs in a co-routine. I suggest digging deeper into the update manager if you want to know more.

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
Re: LagPosition
« Reply #2 on: July 03, 2012, 03:00:09 PM »
Thanks. I dug in deeper after I asked the question and finally figured it out. You actually are running a single CoRoutine that executes all the methods passed to run as 'CoRoutines' once per frame (via a yield return null).
This single CoRoutine is customized in UpdateManager to ignore deltaTime.

I think it was the method naming and the need to read the code as 'documentation' that took me so long to figure out.

Thanks for the quick response.
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.