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

Curious how to add new enemy scripting/behavior in on-demand asset bundles

Discussion in 'Scripting' started by mistergreen2016, Aug 16, 2017.

  1. mistergreen2016

    mistergreen2016

    Joined:
    Dec 4, 2016
    Posts:
    226
    I'm planning to do in app purchase of new game levels/scenes.
    So i'm reading up on https://bitbucket.org/Unity-Technologies/assetbundledemo

    So assets are data files, images, sound; no executables like c#.

    How do you introduce new enemies that require new scripts in the new levels?
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    You can't add a new script to an asset bundle that isn't in the project. So, let's say I want to introduce a troll enemy and I create a troll script. The troll script is brand new but doesn't exist in the project that the players are currently playing. Releasing the troll enemy will not work as they don't have the troll script.

    You would have to update the project to have the troll script in it, then you could release the troll enemy, since the project would have the troll script now in it.

    Now, there is a way around this, but note the limitations as listed here https://docs.unity3d.com/550/Documentation/Manual/scriptsinassetbundles.html
     
  3. mistergreen2016

    mistergreen2016

    Joined:
    Dec 4, 2016
    Posts:
    226
    I see. So it's easier to just update the app and unlock the level on purchase.
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Or define your enemy behavior in a higher level scripting language like Lua that you interpret at runtime. You can include Lua scripts as text asset files in your assetbundles.