How to allow Update / FixedUpdate just once per object at a time?

Basically I have one script I use for a few objects. I don’t want to allow a few objects execute FixedUpdate at the same time. I want to use something like synchronized in java or something like that, to allow only one object to use FixedUpdate at a time. Is it possible?

You can create a static variable at the top of the file:

static var usedThisFrame = false;

Then in LateUpdate():

function LateUpdate() {
    usedThisFrame = false;
}

Finally in Update():

function Update() {
    if (!usedThisFrame) {
       // Do whatever
       usedThisFrame = true;
   }
}

As an alternate solution, you can use Time.frameCount:

At the top of the file:

static var frameCount = 0;

Then in Update():

function Update() {
    if (frameCount != Time.frameCount) {
        // Do whatever
        frameCount = Time.frameCount;
    }
}