annotate Chapter5/Assets/SimpleCloudSystem by RM/SCS.js @ 2:fdab88fc2cb9

add game projects
author Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
date Fri, 17 Jul 2015 23:14:45 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 var Player : Transform;
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 var CloudsSpeed: float;
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 private var distance = 10.0;
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 private var height = 0;
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 private var heightDamping = 0;
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 private var rotationDamping = 0;
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 function Update() {
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 transform.Rotate(0,Time.deltaTime*CloudsSpeed ,0);
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 // rotate 90 degrees around the object's local Y axis:
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 }
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 function LateUpdate () {
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 if (!Player)
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 return;
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 var wantedHeight = Player.position.y + height;
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 var currentHeight = transform.position.y;
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 currentHeight = Mathf.Lerp (currentHeight, wantedHeight, heightDamping * Time.deltaTime);
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 transform.position = Player.position;
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 transform.position.y = currentHeight;
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33
fdab88fc2cb9 add game projects
Yuta ANSE <e135745@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 }