---
title: "GetComponent "
content_type: tutorial
url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente?language=es"
language: es
difficulty: beginner
duration_minutes: 5
unity_version:
  - "2019.3"
  - "2019.2"
  - "2019.1"
  - "2018.4"
  - "2018.3"
  - "2018.2"
  - "2018.1"
  - "2017.4"
  - "2017.3"
  - "2017.2"
  - "2017.1"
  - "5.x"
  - "4.x"
supported_unity_versions:
  - name: "2019.3"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=2018.4"
  - name: "2018.3"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=2018.3"
  - name: "2018.2"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=2018.2"
  - name: "2018.1"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=2018.1"
  - name: "2017.4"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=2017.4"
  - name: "2017.3"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=2017.3"
  - name: "2017.2"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=2017.2"
  - name: "2017.1"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=2017.1"
  - name: "5.x"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=5.x"
  - name: "4.x"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es&version=4.x"
available_languages:
  - name: "en"
    url: "https://learn.unity.com/tutorial/getcomponent.md?language=en"
  - name: "es"
    url: "https://learn.unity.com/tutorial/getcomponent-obtener-el-componente.md?language=es"
  - name: "ja"
    url: "https://learn.unity.com/tutorial/getcomponent-noshi-ifang.md?language=ja"
  - name: "ko"
    url: "https://learn.unity.com/tutorial/getcomponent-2.md?language=ko"
  - name: "zh-cn"
    url: "https://learn.unity.com/tutorial/getcomponent-1.md?language=zh-cn"
last_updated: "2026-08-04T14:22:29.000Z"
---

# GetComponent 

Aprende a usar la función GetComponent para acceder y trabajar con las propiedades de otros scripts y componentes de tu proyecto.

Cómo se usa la función GetComponent (Obtener el componente) para dirigirse a las propiedades de otros _scripts_ u otros componentes.

Este tutorial está incluido en el proyecto [_Scripting_ para principiantes. ](https://learn.unity.com/project/scripting-para-principiantes)

Previo: OnMouseDown

Siguiente: DeltaTime

## 1. GetComponent (Obtener el componente)

[Video](http://www.youtube.com/watch?v=xbDKC4zP9XY)

## **UsingOtherComponents**

```csharp
using UnityEngine;
using System.Collections;

public class UsingOtherComponents : MonoBehaviour
{
    public GameObject otherGameObject;
    
    
    private AnotherScript anotherScript;
    private YetAnotherScript yetAnotherScript;
    private BoxCollider boxCol;
    
    
    void Awake ()
    {
        anotherScript = GetComponent<AnotherScript>();
        yetAnotherScript = otherGameObject.GetComponent<YetAnotherScript>();
        boxCol = otherGameObject.GetComponent<BoxCollider>();
    }
    
    
    void Start ()
    {
        boxCol.size = new Vector3(3,3,3);
        Debug.Log("The player's score is " + anotherScript.playerScore);
        Debug.Log("The player has died " + yetAnotherScript.numberOfPlayerDeaths + " times");
    }
}
```

## **AnotherScript**

```csharp
using UnityEngine;
using System.Collections;

public class AnotherScript : MonoBehaviour
{
    public int playerScore = 9001;
}
```

## **YetAnotherScript**

```csharp
using UnityEngine;
using System.Collections;

public class YetAnotherScript : MonoBehaviour
{
    public int numberOfPlayerDeaths = 3;
}
```
