質問編集履歴

1

修正

2018/08/20 10:00

投稿

GOTOken
GOTOken

スコア54

test CHANGED
File without changes
test CHANGED
@@ -4,6 +4,52 @@
4
4
 
5
5
 
6
6
 
7
+ ```c#
8
+
9
+ private void FixedUpdate()
10
+
11
+ {
12
+
13
+
14
+
15
+ float x = Input.GetAxisRaw("Horizontal");
16
+
17
+
18
+
19
+ if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Joystick1Button1))
20
+
7
- ```rb2d.AddForce(Vector2.up * jumpPower);```
21
+ rb2d.AddForce(Vector2.up * jumpPower);
22
+
23
+ //左か右を入力したら
24
+
25
+ if (x != 0)
26
+
27
+ {
28
+
29
+ rb2d.velocity = new Vector2(x * spped, rb2d.velocity.y);
30
+
31
+ Vector2 temp = transform.localScale;
32
+
33
+ if (x < 0.1 || x > -0.1)
34
+
35
+ temp.x = Mathf.Sign(x);
36
+
37
+ transform.localScale = temp;
38
+
39
+ }
40
+
41
+ else
42
+
43
+ {
44
+
45
+ rb2d.velocity = new Vector2(0,rb2d.velocity.y);
46
+
47
+ }
48
+
49
+ }
50
+
51
+
52
+
53
+ ```
8
54
 
9
55
  以下のような書き方をし、ジャンプの挙動の実装を試みました。ですが、Rigidbodyの仕様なのか、唐突に大ジャンプを繰り広げるときがあります。この場合の解決方法はどのようなものがあるのかご教授していただけると嬉しいです。