my gameObject sometime need to check it immediately.
it’s not case of onCollisionxxx(Enter, Stay, Exit).
so i want check collision myself, how can i do it?
the gameObject has BoxCollision.(unitArea) and CircleCollision(AttackRange area)
gameObject [A] check about [A]'s AttackRange and [B]'s unitArea.
now i use this (Rect vs Circle)
cc.Intersection.polygonCircle();
( did not have cc.Intersection.RectCircle? so i use to polygonCircle() )
// create target's rect every time when need to check it
let tArea: cc.BoxCollider = this.target.unitArea;
let targetRect: cc.Rect = new cc.Rect(this.target.node.x + tArea.offset.x, this.target.node.y + tArea.offset.y, tArea.size.width, tArea.size.height);
if(cc.Intersection.polygonCircle(
[cc.v2(targetRect.x, targetRect.y), cc.v2(targetRect.x + targetRect.width, targetRect.y),
cc.v2(targetRect.x + targetRect.width, targetRect.y + targetRect.height), cc.v2(targetRect.x, targetRect.y + targetRect.height)],
{
position: this.node.position,
radius: this.attackRange.radius // this.attackRange: cc.CircleCollider
}))) {
// do process collision
}
cc.BoxCollider, cc.CircleCollider has not cc.Rect and Circle.
it’s create new rect object every time when need to check it.
i think is it low efficiency.
how can i check intersect cc.BoxCollider and cc.CircleCollider directly?
please tell me, any idea, any advice!