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

Transform.Parent = null ?

Discussion in 'Multiplayer' started by maryuma888, Nov 12, 2022.

  1. maryuma888

    maryuma888

    Joined:
    Nov 2, 2018
    Posts:
    11
    Hey guys,
    Simple question I cannot figure out.
    Trying to access parent transform from its childobject
    upload_2022-11-12_13-41-54.png
    'canvasBoard' is the 'Canvas' gameObject
    upload_2022-11-12_13-42-23.png

    the transform.parent should return the 'Player_prefab' transform but on Multiplayer 'add Host' it always return null.
    why is that?
    thanks
     
  2. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    Hey @maryuma888 , I'm assuming your script is on the Player_Prefab (is it?) so in that case the issue is that you're accessing transform.parent instead of canvasBoard.transform.parent , as with this setup transform refers to the Player_Prefab's transform.

    Does this fix your issue?
     
  3. iMobCoding

    iMobCoding

    Joined:
    Feb 13, 2017
    Posts:
    164
    Either what @RikuTheFuffs-U already suggested or ControllStabilize is indeed located on your Canvas object but you forgot to reference canvasBoard in the inspector.
     
    RikuTheFuffs-U likes this.