Im sorry for double posting again, but i figured it out how to get the collider in a rect:
new Rect(
(gameObject.transform.localPosition.x+currentSprite.CurrentSprite.customColliders[i].origin.x)-currentSprite.CurrentSprite.customColliders[i].Size.x/2,
(gameObject.transform.localPosition.y+currentSprite.CurrentSprite.customColliders[i].origin.y)-currentSprite.CurrentSprite.customColliders[i].Size.y/2,
currentSprite.CurrentSprite.customColliders[i].Size.x,
currentSprite.CurrentSprite.customColliders[i].Size.y);
Now all i got to do is to
Rect.Overlap
and manage the collider names.
Thanks Unikron! your asset rocks!
See ya!
Edit:
Haha, sorry for bothering so much, but now i've found another problem.
My character faces the opponent, so when the x of the opponent is higher than the characters x I set mySprite.FlipX to false, and when it's lower, i set to true.
But the Advanced Collision Boxes doesn't follow this rule. They're all in the same place, even if the sprite is flipped.
Can you help me with that?
THANKS!
Edit 2:
Well, i've managed to make that. If anyone faces this problem, here's how to solve it:
float originX = (currentSprite.FlipX) ? -currentSprite.CurrentSprite.customColliders[i].origin.x : currentSprite.CurrentSprite.customColliders[i].origin.x;
Rect collisionRect = new Rect(
(gameObject.transform.localPosition.x+originX)-currentSprite.CurrentSprite.customColliders[i].Size.x/2,
(gameObject.transform.localPosition.y+currentSprite.CurrentSprite.customColliders[i].origin.y)-currentSprite.CurrentSprite.customColliders[i].Size.y/2,
currentSprite.CurrentSprite.customColliders[i].Size.x,
currentSprite.CurrentSprite.customColliders[i].Size.y);
Here is it working:
I made a DrawRect to see in inspector where were the lines, here's the code piece:
void DrawRect(Rect r, Color c){
Debug.DrawLine(new Vector3(r.x, r.y, 0), new Vector3(r.x +r.width,r.y,0),c);
Debug.DrawLine(new Vector3(r.x+r.width, r.y,0), new Vector3(r.x+r.width,r.y+r.height,0),c);
Debug.DrawLine(new Vector3(r.x+r.width, r.y + r.height, 0), new Vector3(r.x, r.y+r.height,0),c);
Debug.DrawLine(new Vector3(r.x, r.y+r.height, 0), new Vector3(r.x, r.y, 0),c);
}
See ya