๋ด๊ฐ ๋ค๋ฅธ๊ณณ์์ ์ฌ๋ฌ๊ตฐ๋ฐ ์ฐพ์๋ณด๋ค๊ฐ itween์ผ๋ก ํฌ๋ฌผ์ ํ๋ ค๊ณ ํ๋๋ฐ ์ ์๋์ ๋ค๋ฅธ๊ณณ์์ย ๋ด๊ฐ ์ํ๋ ์ฝ๋ ์ฐพ์์ ์ฌ๊ธฐ์ ์ ์ด๋ด
https://answers.unity.com/questions/1515853/move-from-a-to-b-using-parabola-with-or-without-it.html
์ฌ๊ธฐ์ฝ๋ ์ฌ์ฉํ์.
์ด๊ฑด ๋ถ๋ชจ์ ๋ฃ๊ณ ํฌ๋ฌผ์ ์ฌ์ฉํ๋ ์์์ค๋ธ์ ํธ์์ ๋ถ๋ฌ์ด
protected void Parabolic(Vector3 start, Vector3 end, float time)
{
float heigh = 3;
float target_X = start.x + (end.x - start.x) * time;
float target_Y = start.y + (end.y - start.y) * time + heigh * (1 - (Mathf.Abs(0.5f - time) / 0.5f) * (Mathf.Abs(0.5f - time) / 0.5f));
this.transform.position = new Vector3(target_X, target_Y);
}
์ด๊ฑด ์ด์ ๋ ์๊ฐ๋๊ฑฐ
public class Attack : MonoBehaviour
{
ย ย private Vector3 startPos; //์์ํ๋ ์์น
ย ย private float preTime; //์ด๊ธฐ ์๊ฐ
ย ย private float duration = 0.7f; //์๋(๋ฎ์์๋ก ๋นจ๋ผ์ง)
ย ย private void Start()
ย ย {
ย ย ย ย startPos = this.transform.position;
ย ย ย ย preTime = Time.time;
ย ย }
ย ย void Update()
ย ย {
ย ย ย ย //ํฌ๋ฌผ์ ์ด๋
ย ย ย ย Parabolic(startPos, target.transform.position, (Time.time - preTime) / duration);
ย ย ย ย //์ด์์ด ํ๋ฉด ๋ฐ์ผ๋ก ๋๊ฐ๊ฒฝ์ฐ ํ๊ดด
ย ย ย ย if (this.transform.position.x < Camera.main.ScreenToWorldPoint(this.transform.position).x)
ย ย ย ย ย ย Destroy(this.gameObject);
ย ย }
}
๋ ํผ์ ๊ณต๋ถํ๋๊ฑฐ๋ผ ์ต์ ํ๋ ๋ชจ๋ฅด๊ฒ ๊ณ ์์์๋ค ์ฐ๋ผ๋๊ฑฐ์ง ใ ;;
DOTWeen์ฐ๋ฉด ํ๋ฐฉ์ธ๊ฑธ;;