質問編集履歴
5
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -158,7 +158,7 @@
|
|
158
158
|
|
159
159
|
Debug.Log("位置:"+ this.transform.position.ToString("G"));
|
160
160
|
|
161
|
-
Debug.Log("算出:"+ (this.transform.position + rigidbody.velocity*Time.deltaTime + 1/2*acc*Time.deltaTime*Time.deltaTime).ToString("G"));
|
161
|
+
Debug.Log("算出:"+ (this.transform.position + rigidbody.velocity*Time.deltaTime + 1f/2f*acc*Time.deltaTime*Time.deltaTime).ToString("G"));
|
162
162
|
|
163
163
|
}
|
164
164
|
|
4
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -122,11 +122,13 @@
|
|
122
122
|
|
123
123
|
### 追記2
|
124
124
|
|
125
|
-
加速度あり
|
125
|
+
加速度あり
|
126
126
|
|
127
127
|
|
128
128
|
|
129
129
|
```C#
|
130
|
+
|
131
|
+
|
130
132
|
|
131
133
|
void FixedUpdate()
|
132
134
|
|
@@ -142,9 +144,11 @@
|
|
142
144
|
|
143
145
|
Vector3 force = new Vector3(x * speed, y * speed, 0);
|
144
146
|
|
147
|
+
Vector3 relativeforce = this.transform.TransformDirection(force);
|
148
|
+
|
149
|
+
Vector3 acc = relativeforce/rigidbody.mass;
|
150
|
+
|
145
151
|
rigidbody.AddRelativeForce(force);
|
146
|
-
|
147
|
-
|
148
152
|
|
149
153
|
|
150
154
|
|
@@ -154,7 +158,7 @@
|
|
154
158
|
|
155
159
|
Debug.Log("位置:"+ this.transform.position.ToString("G"));
|
156
160
|
|
157
|
-
Debug.Log("算出:"+ (this.transform.position +
|
161
|
+
Debug.Log("算出:"+ (this.transform.position + rigidbody.velocity*Time.deltaTime + 1/2*acc*Time.deltaTime*Time.deltaTime).ToString("G"));
|
158
162
|
|
159
163
|
}
|
160
164
|
|
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -84,7 +84,7 @@
|
|
84
84
|
|
85
85
|
### 追記
|
86
86
|
|
87
|
-
|
87
|
+
加速度0のコードのはず。
|
88
88
|
|
89
89
|
```C#
|
90
90
|
|
@@ -117,3 +117,45 @@
|
|
117
117
|
}
|
118
118
|
|
119
119
|
```
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
### 追記2
|
124
|
+
|
125
|
+
加速度あり。
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
```C#
|
130
|
+
|
131
|
+
void FixedUpdate()
|
132
|
+
|
133
|
+
{
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
float x = Input.GetAxis("Horizontal");
|
138
|
+
|
139
|
+
float y = Input.GetAxis("Vertical");
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
Vector3 force = new Vector3(x * speed, y * speed, 0);
|
144
|
+
|
145
|
+
rigidbody.AddRelativeForce(force);
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
if(rigidbody.velocity.magnitude > 0){
|
152
|
+
|
153
|
+
Debug.Log("-----");
|
154
|
+
|
155
|
+
Debug.Log("位置:"+ this.transform.position.ToString("G"));
|
156
|
+
|
157
|
+
Debug.Log("算出:"+ (this.transform.position + (rigidbody.velocity + force) * Time.deltaTime).ToString("G"));
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
```
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -88,6 +88,22 @@
|
|
88
88
|
|
89
89
|
```C#
|
90
90
|
|
91
|
+
void FixedUpdate()
|
92
|
+
|
93
|
+
{
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
float x = Input.GetAxis("Horizontal");
|
98
|
+
|
99
|
+
float y = Input.GetAxis("Vertical");
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
rigidbody.velocity = new Vector3(x*speed, 0, 0);
|
104
|
+
|
105
|
+
|
106
|
+
|
91
107
|
if(rigidbody.velocity.magnitude > 0){
|
92
108
|
|
93
109
|
Debug.Log("-----");
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -79,3 +79,25 @@
|
|
79
79
|
Vector3 worldMax = Camera.main.ViewportToWorldPoint(viewMax)
|
80
80
|
|
81
81
|
```
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
### 追記
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
```C#
|
90
|
+
|
91
|
+
if(rigidbody.velocity.magnitude > 0){
|
92
|
+
|
93
|
+
Debug.Log("-----");
|
94
|
+
|
95
|
+
Debug.Log("Time.deltaTime:"+Time.deltaTime);
|
96
|
+
|
97
|
+
Debug.Log("位置:"+ this.transform.position.ToString("G"));
|
98
|
+
|
99
|
+
Debug.Log("算出:"+ (this.transform.position + rigidbody.velocity * Time.deltaTime).ToString("G"));
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
```
|