# Новая версия

Новая версия: Unity 2019.3.13f1 (64-bit)

### Использование анимационной кривой

```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CurveScript : MonoBehaviour
{
    public AnimationCurve MyCurve;

    void Update()
    {
        float moveSpeed = 5.0f;
        gameObject.transform.Translate(0, 0, Time.deltaTime * moveSpeed * MyCurve.Evaluate(Time.time));
    }
}
```

### Медленный поворот лицом к цели

```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GoalRotate : MonoBehaviour
{
    public GameObject MyTargetElement;
    
    void Update()
    {
        float speedRotation = 15.0f;
        Vector3 targetVector = new Vector3(
            MyTargetElement.transform.position.x,
            transform.position.y,
            MyTargetElement.transform.position.z);
        Vector3 pos = targetVector - gameObject.transform.position;
        Quaternion rotationBuffer = Quaternion.LookRotation(pos);
        gameObject.transform.rotation = Quaternion.RotateTowards(
            gameObject.transform.rotation, 
            rotationBuffer, 
            speedRotation * Time.deltaTime);
    }
}
```

### Анимация текстуры

```
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class TextureControl : MonoBehaviour
{
    void Update()
    {
        float mySpeedXXX = 0.4f;
        float mySpeedYYY = 0.2f;
        MeshRenderer meshScript = gameObject.GetComponent<MeshRenderer>();
        Vector2 offset = new Vector2(
            meshScript.material.mainTextureOffset.x + Time.deltaTime * mySpeedXXX,
            meshScript.material.mainTextureOffset.y + Time.deltaTime * mySpeedYYY
            );
        meshScript.material.mainTextureOffset = offset;
        Debug.Log(meshScript.material.mainTextureOffset);
    }
}
```

#### Запуск анимации

```
if (Input.GetKeyDown(KeyCode.D))
{
    GameObject obj = GameObject.Find("blenderMyObj");
    Animator anim = obj.GetComponent<Animator>();
    anim.CrossFade("a2", 0);
}
```

#### Получение дочерних элементов

```
_wheelsA = gameObject.transform.Find("wheelsPivot").gameObject;
_wheelsB = gameObject.transform.Find("turningWheelPivot").gameObject;
/////
_resistor = gameObject
    .transform.Find("rigPivot").gameObject
    .transform.Find("handEndPivot").gameObject
    .transform.Find("PartResistor").gameObject;
/////
```
