Hi!
We have two object A and B and these objects have inside a BoxCollider script.
Is it possible, when we want, verify these boxcollider when intersect between them? for sample in a cicly for; for(var i = 0; i < objects; i++) etc… because we move (without physic) an object and we want verify the collision with others objects when we move them.
short version, you have to implement onCollisionEnter (and onCollisionStay/onCollisionExit, depending on your specs) in a component of a node that also has a XYZCollider attached.
thanks for answer but this don’t resolve our trouble because we don’t use the physics so when we move our player we need to control intersection inside move routine to stop the routine. (when we hit a wall for sample)
collision manager (BoxCollider/CircleCollider/PolygonCollider classes and related) is separated from the physics engine and it just provides collision detection. collision response is programmers’ task to implement.
public onCollisionEnter(other) {
if (other.getComponent(Wall) {
stopMovement();
}
}
yep, we just use for other section inside game this. but in this trouble we move object and before set the next position, we control if next position is valid or invalid. for sample:
for(var i = 0; i < precision; i++) {
var x = this.node.x + stepx;
if(!intersect(rect, obstace.rect)) // < check collision from boxcollider
this.node.x += stepx;
else
skip
}
is not possible have the rect from boxcollider and use rect.intersect for these rects found?