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

Size of a ollider

Discussion in 'Scripting' started by Perci_Alex, May 28, 2020.

  1. Perci_Alex

    Perci_Alex

    Joined:
    May 18, 2020
    Posts:
    5
    Hi, I am following a tutorial about slope in my character movement. I am pretty new in scripting.

    The guide is using a 2D collider the ".size" function to get the size of it collider. The problem is I can't use a 2D collider in my game and I can't find a way the replicated the for a 3D collider.

    Here is the link of the tutorial if needed at 2:30


     

    Attached Files:

  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,748
    3D colliders have "bounds" instead. The Bounds struct has an "extents" Vector3 which is its size.
     
  3. Perci_Alex

    Perci_Alex

    Joined:
    May 18, 2020
    Posts:
    5
    so I would write something like
    colliserSize = cc.bounds;
    ?
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,748
    Should be cc.bounds.extents
     
  5. Perci_Alex

    Perci_Alex

    Joined:
    May 18, 2020
    Posts:
    5
    i see no red. thx :) ill keep in touch if it works fine late on