I find that simply access rigidbody in update will trigger GC Alloc every frame in profiler. Any one can explain it? I am using unity 4.5.1f3
void Update () {
if (rigidbody != null)
{
}
}
I find that simply access rigidbody in update will trigger GC Alloc every frame in profiler. Any one can explain it? I am using unity 4.5.1f3
void Update () {
if (rigidbody != null)
{
}
}
I don’t know why it’s triggering GC Alloc, but there was an article in unity documentation called “Performance and Optimization” (can’t find it now). It said “always cache components like transform. rigidbody, etc…” because all of those getters can be slow and have side effects