- Home /
Question by
Kaji-Atsushi · Oct 18, 2015 at 02:50 AM ·
rigidbody2dcollision detectioncollider2ddynamicedge
Is it possible to have continuous collision detection with dynamic points on Edge Colliders?
Hello All, I'm trying to have continuous collision detection on an edge collider that has dynamic/changing points. I have collision detection set to continuous on the rigidbody component. Unfortunately, this doesn't seem to help. I assume because the points are deleted and recreated not fast enough in FixedUpdate function.
Any pointers would be great! Thanks!
P.s. I know it may be possible to create multiple single line edge colliders to mimic what I'm trying to do here. But that causes me to figure out a way to have all those colliders act as one collider, in order to get one trigger call when an object colliders with multiple colliders.
#pragma strict
var startPoint:Transform;
var centerPoint:Transform;
var endPoint:Transform;
var edgeCollider:EdgeCollider2D;
var vecArray:Vector2[];
function Start () {
edgeCollider = this.GetComponent.<EdgeCollider2D>();
vecArray = new Vector2[3];
// edgeCollider.points = new Vector2[3];
}
function FixedUpdate(){
edgeCollider.points = vecArray;
vecArray[0] = Vector2(startPoint.position.x,startPoint.position.y);
vecArray[1] = Vector2(centerPoint.position.x,centerPoint.position.y);
vecArray[2] = Vector2(endPoint.position.x,endPoint.position.y);
}
Comment