Performance: Transform component (position, rotation, scale)
MEDIUM IMPACT
This affects frame rendering speed and smoothness by how often and how complex the transform changes are processed in the scene graph.
Vector3 velocity = new Vector3(0.1f, 0, 0); void Update() { transform.position += velocity * Time.deltaTime; }
void Update() {
transform.position = new Vector3(transform.position.x + 0.1f, transform.position.y, transform.position.z);
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Direct position set every frame | N/A (scene graph nodes) | 1 matrix recalculation per frame | Low | [X] Bad |
| Using velocity with Time.deltaTime | N/A | 1 matrix recalculation per frame | Low | [OK] Good |
| Euler angle conversion every frame | N/A | 2 conversions + 1 matrix recalculation | Medium | [X] Bad |
| Using transform.Rotate incremental | N/A | 1 matrix recalculation | Low | [OK] Good |
| New Vector3 allocation every frame for scale | N/A | 1 matrix recalculation + GC pressure | Medium | [X] Bad |
| Reusing Vector3 instance for scale | N/A | 1 matrix recalculation | Low | [OK] Good |