Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How instantiate entity parent?

Discussion in 'Entity Component System' started by treviasxk, Jul 23, 2023.

  1. treviasxk

    treviasxk

    Joined:
    Apr 22, 2015
    Posts:
    33
    Hey guys. I'm trying to instantiate a weapon on my character as a parent, but I don't know how to create a parent in dots, can anyone help?
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,556
    You want to instantiate Entity that is a parent, as normally you instantiate entities.
    Then add parent component to child entity, if doesn't exits and set to the parent component the parent entity.
    DOTS API should handle rest and in next frame you should be good to go.
     
  3. treviasxk

    treviasxk

    Joined:
    Apr 22, 2015
    Posts:
    33
    I want to instantiate the weapon in the hand hierarchy, so that when I move the bones of the hand, it will follow along.
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,556
    Then you can simply instantiate weapon entity and assign it's parent compinemt to hand entity.