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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    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:
    302
    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:
    151
    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.