-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMove_iTween.cs
More file actions
41 lines (33 loc) · 1.13 KB
/
Move_iTween.cs
File metadata and controls
41 lines (33 loc) · 1.13 KB
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
31
32
33
34
35
36
37
38
39
40
41
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Move_iTween : MonoBehaviour {
public Vector3 prev;
public bool finish = false;
readonly int FPS = 100;
// Use this for initialization
void Start () {
MoveTo();
StartCoroutine(RotateObject());
}
IEnumerator RotateObject(){
prev = transform.position;
while (!finish){
yield return new WaitForSeconds((float) 1 / FPS);
Vector3 direc = transform.position - prev;
transform.eulerAngles = new Vector3(0 , Mathf.Atan2(direc.x, direc.z) * Mathf.Rad2Deg , 0);
prev = transform.position;
}
}
void ChangeFinishTag(){
finish = true;
}
void MoveTo(){
Hashtable moveSetting = new Hashtable();
moveSetting.Add("time", 5.0f);
moveSetting.Add("easetype", iTween.EaseType.linear);
moveSetting.Add("path", iTweenPath.GetPath("PathTest"));
moveSetting.Add("oncomplete", "changeFinishTag");
iTween.MoveTo(this.gameObject , moveSetting);
}
}