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

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:
    432
    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:
    161
    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.