Upcoming SlideShare
×

# 玉転がしゲームで学ぶUnity入門

49,283 views

Published on

http://www.ustream.tv/recorded/14715477

Published in: Education
26 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
49,283
On SlideShare
0
From Embeds
0
Number of Embeds
12,177
Actions
Shares
0
159
0
Likes
26
Embeds 0
No embeds

No notes for slide

### 玉転がしゲームで学ぶUnity入門

1. 1. Unity
2. 2. ※ http://www.ustream.tv/recorded/14715477
3. 3. • Hierarchy Cube
4. 4. • Floor
5. 5. • Position 0, 0, 0
6. 6. • Scale 10, 1, 30
7. 7. • Project Material
8. 8. • FloorMaterial•
9. 9. • Hierarchy Floor
10. 10.
11. 11. • Hierarchy Directional light
12. 12. •• ) Position -3, 9, -7 Rotation 38, 0, 0
13. 13. Player( )
14. 14. • Hierarchy Sphere
15. 15. • Player• Position 0, 3, -5
16. 16. • Project Material• PlayerMaterial
17. 17. • Project ※ http://d.hatena.ne.jp/nakamura001/ﬁles/net.png
18. 18. • PlayerMaterial
19. 19. • Player
20. 20. • MainCamera Position 0, 6, -10• Rotation 40, 0, 0
21. 21. Player( )
22. 22. Player• Project JavaScript
23. 23. Player• PlayerAction• Player
24. 24. JavaScriptvar power = 20.0;function Update () {! var x = Input.GetAxis("Horizontal") * Time.deltaTime * power;! var z = Input.GetAxis("Vertical") * Time.deltaTime * power;! Debug.Log("x="+x+", z="+z);! transform.Translate(x, 0, z);}
25. 25.
26. 26.
27. 27. • Player Rigidbody
28. 28. PackageProjectImport Package→Physic Materials
29. 29. Package• import
30. 30. • Ice Player Sphere Collider Material
31. 31. JavaScriptvar power = 80.0;function Update () {! var x = Input.GetAxis("Horizontal") * Time.deltaTime * power;! var z = Input.GetAxis("Vertical") * Time.deltaTime * power;! Debug.Log("x="+x+", z="+z);! rigidbody.AddForce(x, 0, z);}
32. 32.
33. 33. JavaScriptvar power = 80.0;var jumpPower = 300.0;function Update () {! var x = Input.GetAxis("Horizontal") * Time.deltaTime * power;! var z = Input.GetAxis("Vertical") * Time.deltaTime * power;! Debug.Log("x="+x+", z="+z);! rigidbody.AddForce(x, 0, z);! if (Input.GetButtonDown("Jump")) {! ! Debug.Log("Jump");! ! rigidbody.AddForce(0, jumpPower, 0);! }}
34. 34.
35. 35. • Hierarchy Cube• Goal• Position 0, 1.4, 0 Scale 2, 2, 2
36. 36. • Project Material• GoalMaterial
38. 38. • GoalMaterial Goal
39. 39. • GUI Text GameClear
40. 40. • Text GAME CLEAR• Anchor middle center• Font Size 40
41. 41. Goal JavaScript
42. 42. JavaScript• JavaScript• GoalAction• Goal
43. 43. JavaScriptprivate var player: GameObject;private var gameClear: GameObject;function Start() {! player = GameObject.Find("Player");! gameClear = GameObject.Find("GameClear");! gameClear.active = false;}function OnCollisionEnter(theCollision : Collision){! if(theCollision.gameObject.name == "Player"){! ! gameClear.active = true;! ! player.rigidbody.Sleep();! ! player.SendMessage("stop");! }}
44. 44. Player JavaScript var power = 80.0; var jumpPower = 300.0; var stopFlag = false; function Update () { ! if (stopFlag) return; ! var x = Input.GetAxis("Horizontal") * Time.deltaTime * power; ! var z = Input.GetAxis("Vertical") * Time.deltaTime * power; ! rigidbody.AddForce(x, 0, z); ! if (Input.GetButtonDown("Fire1")) { ! ! rigidbody.AddForce(0, jumpPower, 0); ! ! Debug.Log("hoge"); ! } } function stop() { ! stopFlag = true; }
45. 45. GetAxis()
46. 46. GetAxis()• GetAxis("Horizontal") Horizontal
47. 47. GetAxis()
48. 48. IDE
49. 49. MonoDevelop• Unity MonoDevelop C# IDE• MonoDevelop Unity
50. 50. MonoDevelop• Unity Assets → Sync MonoDevelop Project MonoDevelop
51. 51. Mac• MonoDevelop MacMac MonoDevelop -http://d.hatena.ne.jp/nakamura001/20110711/1310364725