Function to detect if two objects collides or not