Displaying the first category from a custom taxonomy with get_the_terms

Hello here is an example i have used :

<?php while ( have_posts() ) : the_post(); 

  $category = get_the_terms( $id, 'event_category' );
  //get First Category
  $firstCategory = $category[0];
  //get category link
    $category_link = get_category_link($firstCategory->term_id);
    //echo category name
    echo $firstCategory->name;

 endwhile;
?>   

change event_category with your taxonomy slug