What is func_instance?

Discussion in 'Mapping Questions & Discussion' started by WarmHandSanitizer, Dec 4, 2012.

  1. WarmHandSanitizer

    WarmHandSanitizer L1: Registered

    Messages:
    26
    Positive Ratings:
    0
    You guys have been raving about it, but I didn't get why it was so useful, or even how it worked.

    The wiki didn't provide much help.
     
  2. tyler

    aa tyler snail prince, master of a ruined tower

    Messages:
    5,034
    Positive Ratings:
    3,989
    I don't really think I can explain it better than the wiki does.

    So... it puts a vmf in your vmf.

    Useful for things you repeat a lot, things you need to change all of at once (lights), or angled detail geometry.

    To use it, place a func_instance entity and type the relative vmf filename. If the thing you want to instance is in the same directory, that's just filename.vmf.
     
  3. Fr0Z3nR

    aa Fr0Z3nR Creator of blackholes & memes. Destroyer of forums

    Messages:
    6,391
    Positive Ratings:
    4,906
    You can build a solitary building in a seperate .vmf, and then use func_instance to place that building into another .vmf. (If you want a reallly specific/simple answer) And, as yyler said, it's great for repeating things, weird angle brushwork, or lighting.

    I used it for stairs a couple times.
     
  4. Freyja

    aa Freyja ¯\_(ツ)_/¯

    Messages:
    2,869
    Positive Ratings:
    4,896
    I used func_instance for the bridges in escarpment. It means I could build them on-grid, then rotate them to a weird angle in the main vmf and still be able to go back and edit it later, still on grid.
     
    • Thanks Thanks x 1
  5. WarmHandSanitizer

    WarmHandSanitizer L1: Registered

    Messages:
    26
    Positive Ratings:
    0
    i think i get it now.
     
  6. Pocket

    aa Pocket func_croc

    Messages:
    4,489
    Positive Ratings:
    2,219
    What happens to them when you compile, anyway? Does it hard-code all of the vertices as exact XYZ coordinates (which technically involves snapping everything to a grid, just a much smaller one)? Or does it store it as if it were on grid and then say "rotate it so many degrees"?
     
  7. Trader

    Trader L1: Registered

    Messages:
    13
    Positive Ratings:
    0
    Uh isn't this kind of like inserting a prefab?
     
  8. Idolon

    aa Idolon the worst admin

    Messages:
    1,548
    Positive Ratings:
    4,437
    No. Prefabs are no different than any other brush/entity data you stick into the map, while instances are only entities that reference other map files. Prefabs also do not have the rotation or repetition features mentioned previously.
     
  9. Trader

    Trader L1: Registered

    Messages:
    13
    Positive Ratings:
    0
    So if I have 2 separate maps, one map has a really complex solid structure, if I inserted a func_instance into the other map, and change it about a bit, it will change that same structure in the other map as well?
     
  10. tyler

    aa tyler snail prince, master of a ruined tower

    Messages:
    5,034
    Positive Ratings:
    3,989
    It's not like linking files. It puts one file in another.

    If you change the vmf you use as an instance, it updates in every map you've used it in. You can't edit whatever you've instanced unless you open the file itself. Does that make sense?

    Edit: Here's a picture of one of my instances.

    [​IMG]

    I use this in Hella, and rotate it about 30 degrees. If it wasn't an instance, it'd be off grid after doing that pretty significantly. But since it is, I can open this file and edit it whenever without any problems.

    In Hella it appears like this:

    [​IMG]
     
    • Thanks Thanks x 2
    Last edited by a moderator: Dec 4, 2012
  11. Dïcecübe

    Dïcecübe L3: Member

    Messages:
    114
    Positive Ratings:
    31
    This is intresting. I never heard of this trick.
    Something that can help me with some maps which I'm working on!

    Thanks for telling me (or us who never heard of this)!
     
    Last edited: Dec 5, 2012
  12. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,769
    Positive Ratings:
    5,535
    The tools can handle floating point verts, and store/use/remember them, it just becomes impossible to work with.
     
  13. nightwatch

    aa nightwatch

    Messages:
    640
    Positive Ratings:
    446
    Do the brushes, displacements, entities and such go towards the total entity count, etc of the map you put the instance in?
     
  14. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,769
    Positive Ratings:
    5,535
    Yes. The initial processing of the map by VBSP includes collapsing all instances into the map. The instance "entity" doesn't actually exist, it just tells VBSP to include the data from vmf X with such and such settings.
     
    • Thanks Thanks x 1
  15. Shanghai

    Shanghai L6: Sharp Member

    Messages:
    394
    Positive Ratings:
    217
    That's brilliant. That seems like a much better method of dealing with rotated things. How do content packers handle it?
     
  16. Seba

    aa Seba DR. BIG FUCKER, PHD

    Messages:
    2,363
    Positive Ratings:
    2,365
    So packing works as normal.
     
  17. nightwatch

    aa nightwatch

    Messages:
    640
    Positive Ratings:
    446
    I'm guessing there's no way to get a "preview" of what it will look like in hammer with the instances collapsed - you have to compile and find out, right?
     
  18. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,769
    Positive Ratings:
    5,535
    Err, hammer automatically displays whatever is inside the instance (even to the point of displaying selections WITHIN the instance, if you have both files open in hammer). That's almost the entire point of it, since it would be impossibly difficult to use otherwise.
     
  19. nightwatch

    aa nightwatch

    Messages:
    640
    Positive Ratings:
    446
    I can't be doing it right, then. Are there any other fields I need to be filling out other than the name of the vmf to include?
     
  20. tyler

    aa tyler snail prince, master of a ruined tower

    Messages:
    5,034
    Positive Ratings:
    3,989
    The instance "collapsed" is not an instance. It's part of your main vmf. "Collapsing" means "merging".

    Collapsed into a single vmf.