Nextrek
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
42
43
|
using UnityEngine;
using System.Collections;
public class MoveTo : MonoBehaviour
{
private bool start=false;
private Transform target;
private float time;
private float speed;
public void SetArgs(Transform tar,float t)
{
target = tar;
Vector3 dir = target.position-transform.position;
float dis = dir.magnitude;
speed = dis/t;
time = t;
start = true;
//StartCoroutine(GoToSpaceScene(time));
}
void Update ()
{
if(start)
{
time-=Time.deltaTime;
if(time>=0)
{
Vector3 dir = target.position-transform.position;
dir = dir.normalized*speed;
transform.position+=dir*Time.deltaTime;
}
else
{
PlayVideo.startPlay = true;
start=false;
}
}
}
IEnumerator GoToSpaceScene(float t)
{
yield return new WaitForSeconds(t);
yield return Application.LoadLevelAsync("SpaceScene");
}
}
|