Search Unity

Problem using transform.root with hit colliders and DontDestroyOnLoad?

Discussion in 'Scripting' started by peterpantss, Mar 12, 2018.

  1. peterpantss

    peterpantss

    Joined:
    Sep 24, 2014
    Posts:
    13
    I try to use transform.root for various things in my project (raycasts, ontriggerenter). I feel like it has a strange functionality when used alongside DontDestroyOnLoad. The transform.root then becomes the actual level. I'd prefer it to just be the top level of my character.
     
  2. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    If you have a rigidbody on the char you can say .attachedRigiedbody

    Otherwise you'll have to either make the char the actual root(why is it not BTW?) or search up the chain until you hit a transform with a tag "char" or whatever you decide