回答編集履歴

1

formatting

2020/07/29 12:24

投稿

momomo
momomo

スコア14

test CHANGED
@@ -2,73 +2,73 @@
2
2
 
3
3
  ありがとうございました。
4
4
 
5
- ```ここに言語を入力
5
+ ```C#
6
6
 
7
7
  IEnumerator Start()
8
8
 
9
- {
9
+ {
10
10
 
11
- var p = t1.position;
11
+ var p = t1.position;
12
12
 
13
- while (true)
13
+ while (true)
14
14
 
15
- {
15
+ {
16
16
 
17
- t1.position = p;
17
+ t1.position = p;
18
18
 
19
- var direction = (t2.position - t1.position).normalized;
19
+ var direction = (t2.position - t1.position).normalized;
20
20
 
21
- var distance = Vector2.Distance(t1.position, t2.position);
21
+ var distance = Vector2.Distance(t1.position, t2.position);
22
22
 
23
23
 
24
24
 
25
- var v0 = initSpd;
25
+ var v0 = initSpd;
26
26
 
27
- var M = distance;
27
+ var M = distance;
28
28
 
29
- var T = duration;
29
+ var T = duration;
30
30
 
31
- var tm = M / v0;
31
+ var tm = M / v0;
32
32
 
33
- var vm = v0 / T * tm;
33
+ var vm = v0 / T * tm;
34
34
 
35
- var accel1 = (vm - v0) / (tm - 0);
35
+ var accel1 = (vm - v0) / (tm - 0);
36
36
 
37
- var accel2 = (0 - vm) / (T - tm);
37
+ var accel2 = (0 - vm) / (T - tm);
38
38
 
39
- Debug.Log($"vo={v0}, M={M}, T={T}, tm={tm}, vm={vm}, accel1={accel1}, accel2={accel2}");
39
+ Debug.Log($"vo={v0}, M={M}, T={T}, tm={tm}, vm={vm}, accel1={accel1}, accel2={accel2}");
40
40
 
41
- var v = initSpd;
41
+ var v = initSpd;
42
42
 
43
- var stime = Time.time;
43
+ var stime = Time.time;
44
44
 
45
- var hist = 0f;
45
+ var hist = 0f;
46
46
 
47
- // update
47
+ // update
48
48
 
49
- yield return Utils.Coroutine.WhileForSeconds(T, () =>
49
+ yield return Utils.Coroutine.WhileForSeconds(T, () =>
50
50
 
51
- {
51
+ {
52
52
 
53
- t1.Translate(direction * v * Time.deltaTime);
53
+ t1.Translate(direction * v * Time.deltaTime);
54
54
 
55
- hist += v * Time.deltaTime;
55
+ hist += v * Time.deltaTime;
56
56
 
57
- if (Time.time - stime <= tm)
57
+ if (Time.time - stime <= tm)
58
58
 
59
- v += accel1 * Time.deltaTime;
59
+ v += accel1 * Time.deltaTime;
60
60
 
61
- else
61
+ else
62
62
 
63
- v += accel2 * Time.deltaTime;
63
+ v += accel2 * Time.deltaTime;
64
64
 
65
- });
65
+ });
66
66
 
67
- Debug.Log($"経過時間={Time.time - stime}, 移動距離={hist}, v={v}");
67
+ Debug.Log($"経過時間={Time.time - stime}, 移動距離={hist}, v={v}");
68
68
 
69
- }
69
+ }
70
70
 
71
- }
71
+ }
72
72
 
73
73
 
74
74