質問編集履歴

2

kaizenn

2015/12/09 09:28

投稿

xof3413
xof3413

スコア8

test CHANGED
File without changes
test CHANGED
@@ -1,97 +1,3 @@
1
1
  ゲームオブジェクトの頂点(メッシュの頂点)を移動させて形を変える事が出来るようにしているのですが、制限がないのでどこまでも動いてしまいます。
2
2
 
3
3
  そこで、頂点の移動に制限を設けたいのですが、やり方が分かりません。どなたかわかる方いらっしゃいましたらアドバイスお願いします。
4
-
5
-
6
-
7
- 以下スクリプトの一部です。(・・・は省略の意味です。)
8
-
9
-
10
-
11
- using UnityEngine;
12
-
13
- using System.Collections;
14
-
15
-
16
-
17
- public class test8 : MonoBehaviour {
18
-
19
-
20
-
21
- MeshFilter meshFilter;
22
-
23
- Vector3[] defaultVertices;
24
-
25
- Mesh mesh;
26
-
27
-
28
-
29
- float speed = 5;
30
-
31
-
32
-
33
- void Start () {
34
-
35
- MeshFilter mf = GetComponent<MeshFilter>();
36
-
37
- Vector3[] test = mf.mesh.vertices;
38
-
39
-
40
-
41
- foreach (Vector3 item in test) {
42
-
43
- print(item);
44
-
45
- }
46
-
47
-
48
-
49
- }
50
-
51
-
52
-
53
- // Use this for initialization
54
-
55
- void Awake()
56
-
57
- {
58
-
59
- mesh = GetComponent<MeshFilter> ().mesh;
60
-
61
- defaultVertices = mesh.vertices;
62
-
63
- }
64
-
65
-
66
-
67
- // Update is called once per frame
68
-
69
- void Update()
70
-
71
- {
72
-
73
-
74
-
75
- Vector3[] vertices = mesh.vertices;
76
-
77
-
78
-
79
- if (Input.GetKey ("z")) {
80
-
81
-
82
-
83
- vertices [4].x += speed * Time.deltaTime;
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
- mesh.vertices = vertices;
92
-
93
- mesh.RecalculateBounds ();
94
-
95
- }
96
-
97
- }

1

若葉マークを付けた

2015/12/09 09:28

投稿

xof3413
xof3413

スコア8

test CHANGED
File without changes
test CHANGED
File without changes