Unity
Unity3D - 유니티3D Animation Curve 애니메이션 커브
J-sean
2022. 7. 24. 11:23
반응형
애니메이션 커브를 사용해 보자.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Curve : MonoBehaviour
{
public Transform targetA;
public Transform targetB;
public AnimationCurve lerpCurve;
public Vector3 lerpOffset;
public float lerpTime = 3.0f;
private float timer = 0.0f;
// Update is called once per frame
void Update()
{
timer += Time.deltaTime;
if (timer > lerpTime)
{
timer = lerpTime;
}
float lerpRatio = timer / lerpTime;
Vector3 positionOffset = lerpCurve.Evaluate(lerpRatio) * lerpOffset;
transform.position = Vector3.Lerp(targetA.position, targetB.position, lerpRatio) + positionOffset;
}
}
|
스크립트를 작성한다.
반응형