Новая версия
Unity 2019.3.13f1 (64-bit)
Новая версия: 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);
}
}Анимация текстуры
Запуск анимации
Получение дочерних элементов
Last updated
Was this helpful?