Giter Site home page Giter Site logo

Comments (5)

diplojocus avatar diplojocus commented on July 19, 2024

Hi @TomAnks a typical solution to this would be to instantiate the explosion GameObject from a Prefab that already has the Heavy script attached.

See the docs on prefabs here and here

Your instantiatation sequence might look something like this:

public GameObject explosionPrefab;

void Start() {
   GameObject explosion = (GameObject) Instantiate(explosionPrefab, new Vector3(0, 0, 0), Quaternion.identity);
   Hv_explosion_AudioLib script = explosion.GetComponent<Hv_explosion_AudioLib>();
   // do things with the heavy script
}

from heavy.

TomAnks avatar TomAnks commented on July 19, 2024

Hi Joe, thanks for that. I've not used Unity before this so I'm still figuring things out - I'll let you know how I get on!

from heavy.

diplojocus avatar diplojocus commented on July 19, 2024

No problem, the easiest way to generate the Prefab is to create a gameobject in the heirarchy with all the components you want to use. Then drag it into the Assets/File section and it'll turn into a blue cube. Delete the old gameobject and drag the new prefab back in.

from heavy.

TomAnks avatar TomAnks commented on July 19, 2024

Creating a prefab and referencing it in the Bomb.cs code worked perfectly, thanks Joe!

from heavy.

diplojocus avatar diplojocus commented on July 19, 2024

🎉

from heavy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.