Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Each gameObject has own update and fixedupdate?

Discussion in 'Scripting' started by dansav, Apr 25, 2008.

  1. dansav

    dansav

    Joined:
    Sep 22, 2005
    Posts:
    510
    Does/Can Each GameObject have it's own fixedupdate?

    If so how do you add a fixedUPdate to this cube which is created in my main script?

    cube2 = GameObject.CreatePrimitive(PrimitiveType.Cube);
    cube2.AddComponent(Rigidbody);

    Can I do something like this?
    cube2.fixedUpdate=function(){

    }

    Thanks,

    Dan
     
  2. JavaChilly

    JavaChilly

    Joined:
    Mar 8, 2008
    Posts:
    33
    Write your FixedUpdate function in a script and add the script component to your newly created GO.

    // Adds the script named FoobarScript to the game object
    gameObject.AddComponent ("FoobarScript");