Riddhesh Zaveri
Riddhesh Zaveri

Reputation: 21

Unity Physics performance spikes while updating even a single box collider size at runtime

Unity version : 2020.2.3

I am working on a Evo Pop style game where I have to scale up the cubes at runtime. I am developing a basic prototype of it, I found that even with single cube on terrain, it hits huge spikes if I scale up the cube at runtime.

It generates GC of 0.6kb every frame until the cube is growing (scaling up). Also the Physics.Processing takes around 87%

How to optimize the physics collision when your colliders are scaling up & down at runtime?

Screenshot : profiler enter image description here

Screenshot : physics settings enter image description here

Screenshot : rigidbody settings

enter image description here

Upvotes: 1

Views: 1312

Answers (1)

Rajas
Rajas

Reputation: 338

I would recommend using Tween from Surge Package(Free)

using UnityEngine;
using PixelPlacement;

void ScaleMyBlock(float ScaleOffset)
{
        Tween.LocalScale (transform, initialScale , Vector3.one * ScaleOffset, 1, 0, Tween.linear, Tween.LoopType.None, null, null);
}

You can read more about it here.

Upvotes: 1

Related Questions