-
Notifications
You must be signed in to change notification settings - Fork 0
/
MovingBird.cs
51 lines (37 loc) · 891 Bytes
/
MovingBird.cs
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
44
45
46
47
48
49
50
51
using UnityEngine;
using System.Collections;
public class MovingBird : MonoBehaviour {
public float horizontalSpeed;
public float verticalSpeed;
public float amplitude;
public float[] angle=new float[3];
int i;
Vector3 initialpos ;
private Vector3 tempPosition;
void Start ()
{
angle [0] =0 ;
angle [1] = 1;
angle [2] = -1;
tempPosition = transform.position;
initialpos = new Vector3 (0.0f, 0.0f, -1.63f);
}
void Update ()
{
if(Input.GetKeyDown(KeyCode.A))
{
if(i==3){i = 0;}
tempPosition.x += horizontalSpeed;
tempPosition.y = angle[i] * amplitude;
float y = Mathf.Sin (360);
Debug.Log (tempPosition.y);
transform.position = tempPosition;
i++;
}
if (Input.GetKeyDown (KeyCode.B)) {
transform.position = initialpos;
tempPosition.x = 0.0f;
}
}
}
//Time.realtimeSinceStartup *