I need to check if an object has been transformed, in any way at all, since it’s last check. (position, scale and rotation)
Can i grab and cache the transform.localtoWorldMatrix each check, and compare it against the last cached one? is there a better/more efficient way to accomplish this?
Debugs “true” constantly. Which means that if you compare this frame’s localToWorldMatrix to the last frame’s, you get the same result as if you compared position, rotation and scale.
Now, I have no idea which one is faster - when you just check position, rotation and scale, you should really be caching the transform (as whenever you do transform.position, you’re really doing GetComponent().position), so checking them just accesses three properties of the transform. I doubt any maths happen.
Doing localToWorldMatrix might mean that that matrix has to be calculated - in which case it would be faster to just access the three other properties. It might be that said matrix has to be calculated every frame anyway, and is just cached. In that case, the difference comes down to how fast the == is on matrices.
You could try to run some diagnostics, but to me it looks like comparing the localToWorldMatrice should be just fine for your purpose, and there’s no reason for why it should be slow.