The question is answered, right answer was accepted
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)
You can always inherit from it and make a new one with more data.
public class HitCollider : BoxCollider2D
Assets/HitCollider.cs(5,14): error CS0509: HitCollider': cannot derive from sealed type UnityEngine.BoxCollider2D'
HitCollider': cannot derive from sealed type
My 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)
if (pos = collision.GetComponent<ColliderPos>())
int x = pos.x;
int y = pos.y;
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
76 People are following this question.
Change color of all buttons listed in array
Disable all components but 1 on a gameobject
Get variable in script got by get component c#
Access Animations array in Animation component