Poor Performance in Profiler (transform.position)

Hello Guys !

I am making game for Android Platform Right now…

I have A Cube and I am Trying to Move that from one to another position using Vector3.Lerp()

It Goes Very Fine but I am having very bad spike At that point at

“transform.INTERNAL” for set position

I have attached Script and Image for my Profiler Below…

Please Suggest Solution For Making It Efficient…

Script:

IEnumerator MyCoroutin(Transform Target)
    {

        while (Vector3.Distance (MovingPlatform.position, Target.position)>0.05f) {

            MovingPlatform.position = Vector3.Lerp (MovingPlatform.position,Target.position,movespeeed*Time.deltaTime);

            yield return null;

        }

        yield return new WaitForSeconds (0.1f);
        print("Target Moved");



    }

here is pic for profiler have spike on that place

The spike in the profiler is a bit earlier. The line you have highlighted is only taking 0.07ms which is fine. Total cpu usage at the highlighted line is 1.04ms or 1.84ms which is also fine.

1 Like

Please click on the spike so we can see what code is actually running and consuming frame time.

Its Already on spike

Its already on spike

we have two spikes in above pic…

one is the before few frames which i have selected and another one is the selected in the pic

It’s taking 0.02 milliseconds - how much more efficient do you expect it to be?

I would look into BehaviorUpdate which is taking 0.71ms if you must ( Which is where all your code is run ), also I think the spike was actual a single frame earlier by the looks of the screenshot, and another larger spike a few frames before that

So Is it ok for android platform?

As Well As Mycouritne<> Line NExt Takes 0.3ms can i optimize that?

Seriously?

The things you’re pointing out are part of either the runtime or the engine itself. At a certain point a coroutine has to move to the next yield instruction and a transform has to have a new position applied.

1 Like

Wow, there are 1000ms in a second. Meaning you have 17ms to play with on each frame to get 60FPS.
Dont bother optimising (to a point) unless you are having issues.

EDIT:
Ignore most things that arent your own scripts. Dont even bother.

i didnt get you what you are saying

yeah it doesnt feel you have lag…it gives 60 fps on android…but i want my graph to be work smooth…so thats what i was asking