How to track an object per Frame?

Hey, i am trying to make a simple tracker for my object which will report the changes on that object,like rotation,scale,position etc.The update is pretty slow which i expected that it would be per frame but it is not.Could you point me out where am i wrong here?The update seems to be close to per second.

Thanks.

var time : float = 0;

function Update () {

if(time < 2) {

//cache the data from object at this time

time += 1;

}

if(time > 1) {

//cache the data from object at this time

time = 0;

}

//compare the caches

}

Just store the previous values at the end of each Update function. You don’t need the ‘time’ counter. So the logic for Update() would be:

  • Compare current position, rotation etc to the previous values
  • Do whatever else you want to do in Update
  • Store the current values as ‘previousPosition’, ‘previousRotation’ etc