Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Mar 18, 2017 at 08:40 PM by PixelSpartan for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by PixelSpartan · Mar 18, 2017 at 08:03 PM · arraycomponentboxcollider2dbuilt-in

Add a variable / parameter to a built in component

I want to add 2 integers to the built in boxcollider2d so that i know when hit, what coordinate it coresponds in my 2 dimensional array of a custom class, so is there any way to add those 2 parameters so i can change them like BoxCollider2D.x and BoxCollider2D.y (they are all on 1 object so i cant use actual position)

Comment
Add comment · Show 7
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image RobAnthem · Mar 18, 2017 at 08:09 PM 1
Share

You can always inherit from it and make a new one with more data.

 public class HitCollider : BoxCollider2D
 {
     float hitX;
     float hitY;
 }
avatar image PixelSpartan RobAnthem · Mar 18, 2017 at 08:14 PM 0
Share

Assets/HitCollider.cs(5,14): error CS0509: HitCollider': cannot derive from sealed type UnityEngine.BoxCollider2D'

avatar image RobAnthem PixelSpartan · Mar 18, 2017 at 08:20 PM 0
Share

$$anonymous$$y bad, was an assumption that you could derive from it. Gotta love Unitys sealed classes. Honestly at this point, you ether make a master script that is apart of the same gameobject, or you create a boxcollider array. For the first method, a simple

     void OnCollisionEnter(Collision collision)
     {
         ColliderPos pos;
         if (pos = collision.GetComponent<ColliderPos>())
         {
             int x = pos.x;
             int y = pos.y;
         }
     }
Show more comments

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

72 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity cannot find component of an object in an array. 2 Answers

Change variable of ex2D Sprite using the component ExScreenPosition via code .js script 0 Answers

access the animation array in an animation component. 1 Answer

script communicate with each other 0 Answers

problem with FindWithTag 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges