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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Is there a way that "childs" don't follow "parent" object?

Discussion in 'Scripting' started by Grillstern, Mar 17, 2015.

  1. Grillstern

    Grillstern

    Joined:
    Oct 14, 2013
    Posts:
    32
    Hi,

    Every "Enemie" (GameObject) should have an own path it should follow.
    So every Enemy got a list of childs (= node1, node2, node3,...) which represents its path.
    I can move the Enemie to path node1, but while moving to it the other nodes are moving with the Enemie so that the original position of the nodes are changing. Is there a way thay the child nodes stay at there init. position while only the parent (enemie) is moving?!

    Thx for help.
     
  2. JohnSonLi

    JohnSonLi

    Joined:
    Apr 15, 2012
    Posts:
    586
    No,there isn't.
    think about changing your structure
     
  3. Grillstern

    Grillstern

    Joined:
    Oct 14, 2013
    Posts:
    32
    ok...thx :)
     
  4. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    You can have the children not follow their parent by manually updating their global transforms in Update or FixedUpdate. But if that's the behavior you want, then why are you parenting them in the first place?
     
    Mycroft likes this.
  5. Little_Narwhal_13

    Little_Narwhal_13

    Joined:
    Feb 6, 2017
    Posts:
    15
    I think he wants it so that you can still have a structured hierarchy. For example you might have some waypoint transforms for an enemy and instead of putting them randomly in your hierarchy you would group them under the enemy they correspond to, thing is, if you do so, then they move with the enemy and the enemy will never reach a waypoint..
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If these nodes just store a world position, then I'd replace your system with just a list of Vector3's. Otherwise I would unparent these nodes and put them under a separate GameObject the enemy keeps a reference to.
     
    Munchy2007 likes this.