質問編集履歴
5
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -78,6 +78,6 @@
|
|
78
78
|
if(rigidbody.velocity.magnitude > 0){
|
79
79
|
Debug.Log("-----");
|
80
80
|
Debug.Log("位置:"+ this.transform.position.ToString("G"));
|
81
|
-
Debug.Log("算出:"+ (this.transform.position + rigidbody.velocity*Time.deltaTime +
|
81
|
+
Debug.Log("算出:"+ (this.transform.position + rigidbody.velocity*Time.deltaTime + 1f/2f*acc*Time.deltaTime*Time.deltaTime).ToString("G"));
|
82
82
|
}
|
83
83
|
```
|
4
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -60,9 +60,10 @@
|
|
60
60
|
```
|
61
61
|
|
62
62
|
### 追記2
|
63
|
-
加速度あり
|
63
|
+
加速度あり
|
64
64
|
|
65
65
|
```C#
|
66
|
+
|
66
67
|
void FixedUpdate()
|
67
68
|
{
|
68
69
|
|
@@ -70,12 +71,13 @@
|
|
70
71
|
float y = Input.GetAxis("Vertical");
|
71
72
|
|
72
73
|
Vector3 force = new Vector3(x * speed, y * speed, 0);
|
74
|
+
Vector3 relativeforce = this.transform.TransformDirection(force);
|
75
|
+
Vector3 acc = relativeforce/rigidbody.mass;
|
73
76
|
rigidbody.AddRelativeForce(force);
|
74
77
|
|
75
|
-
|
76
78
|
if(rigidbody.velocity.magnitude > 0){
|
77
79
|
Debug.Log("-----");
|
78
80
|
Debug.Log("位置:"+ this.transform.position.ToString("G"));
|
79
|
-
Debug.Log("算出:"+ (this.transform.position +
|
81
|
+
Debug.Log("算出:"+ (this.transform.position + rigidbody.velocity*Time.deltaTime + 1/2*acc*Time.deltaTime*Time.deltaTime).ToString("G"));
|
80
82
|
}
|
81
83
|
```
|
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -41,7 +41,7 @@
|
|
41
41
|
```
|
42
42
|
|
43
43
|
### 追記
|
44
|
-
|
44
|
+
加速度0のコードのはず。
|
45
45
|
```C#
|
46
46
|
void FixedUpdate()
|
47
47
|
{
|
@@ -57,4 +57,25 @@
|
|
57
57
|
Debug.Log("位置:"+ this.transform.position.ToString("G"));
|
58
58
|
Debug.Log("算出:"+ (this.transform.position + rigidbody.velocity * Time.deltaTime).ToString("G"));
|
59
59
|
}
|
60
|
+
```
|
61
|
+
|
62
|
+
### 追記2
|
63
|
+
加速度あり。
|
64
|
+
|
65
|
+
```C#
|
66
|
+
void FixedUpdate()
|
67
|
+
{
|
68
|
+
|
69
|
+
float x = Input.GetAxis("Horizontal");
|
70
|
+
float y = Input.GetAxis("Vertical");
|
71
|
+
|
72
|
+
Vector3 force = new Vector3(x * speed, y * speed, 0);
|
73
|
+
rigidbody.AddRelativeForce(force);
|
74
|
+
|
75
|
+
|
76
|
+
if(rigidbody.velocity.magnitude > 0){
|
77
|
+
Debug.Log("-----");
|
78
|
+
Debug.Log("位置:"+ this.transform.position.ToString("G"));
|
79
|
+
Debug.Log("算出:"+ (this.transform.position + (rigidbody.velocity + force) * Time.deltaTime).ToString("G"));
|
80
|
+
}
|
60
81
|
```
|
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -43,6 +43,14 @@
|
|
43
43
|
### 追記
|
44
44
|
|
45
45
|
```C#
|
46
|
+
void FixedUpdate()
|
47
|
+
{
|
48
|
+
|
49
|
+
float x = Input.GetAxis("Horizontal");
|
50
|
+
float y = Input.GetAxis("Vertical");
|
51
|
+
|
52
|
+
rigidbody.velocity = new Vector3(x*speed, 0, 0);
|
53
|
+
|
46
54
|
if(rigidbody.velocity.magnitude > 0){
|
47
55
|
Debug.Log("-----");
|
48
56
|
Debug.Log("Time.deltaTime:"+Time.deltaTime);
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -38,4 +38,15 @@
|
|
38
38
|
Vector3 viewMax = new Vector3(1.0f, 1.0f,viewport.z);
|
39
39
|
Vector3 worldMin = Camera.main.ViewportToWorldPoint(viewMin);
|
40
40
|
Vector3 worldMax = Camera.main.ViewportToWorldPoint(viewMax)
|
41
|
+
```
|
42
|
+
|
43
|
+
### 追記
|
44
|
+
|
45
|
+
```C#
|
46
|
+
if(rigidbody.velocity.magnitude > 0){
|
47
|
+
Debug.Log("-----");
|
48
|
+
Debug.Log("Time.deltaTime:"+Time.deltaTime);
|
49
|
+
Debug.Log("位置:"+ this.transform.position.ToString("G"));
|
50
|
+
Debug.Log("算出:"+ (this.transform.position + rigidbody.velocity * Time.deltaTime).ToString("G"));
|
51
|
+
}
|
41
52
|
```
|