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

How to convert UnityEngine.Collider to UnityEngine.GameObject

Discussion in 'Scripting' started by Hooman11, Apr 18, 2021.

  1. Hooman11

    Hooman11

    Joined:
    Apr 15, 2021
    Posts:
    2
    Im wondering if there is a way to convert UnityEngine.Collider to UnityEngine.GameObject

    Im Working on a sign interact and purchase script and now im stuck at this part

    Help

    Also im new to C#
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
  3. Lekret

    Lekret

    Joined:
    Sep 10, 2020
    Posts:
    342
    Collider is component. GameObject is kind of container for components. So they can't be converted into each other, but each component have gameObject associated with it.
    Code (CSharp):
    1. collider.gameObject
     
    Last edited: Apr 19, 2021
    Joe-Censored likes this.
  4. Hooman11

    Hooman11

    Joined:
    Apr 15, 2021
    Posts:
    2
    Thank you guys for the help!!!!
    Thanks a lot!