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

Best way to reference the same prefab from multiple places?

Discussion in 'Prefabs' started by Sirius8844, Apr 20, 2022.

  1. Sirius8844

    Sirius8844

    Joined:
    Jan 14, 2020
    Posts:
    1
    I want to have like 10 types of enemies (they are all prefabs). But on death they will instantiate the same game object (a money pop up text with an animator).

    Is there any other way than making a
    [SerializeField] GameObject
    field inside my "Enemy" script, and dropping the same animation prefab for each of the enemy prefabs?
     
  2. thomasa1972

    thomasa1972

    Unity Technologies

    Joined:
    Oct 11, 2016
    Posts:
    10
    You can avoid dropping the same animation prefab on each of the enemy prefabs, by letting all enemy prefabs become variants of an enemy prefab. That way you can configure the parent enemy prefab once, and have all your enemies share the same property value.