質問編集履歴
1
ボールのコードを書きました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,31 @@
|
|
1
1
|
unityのボールが跳ね返ったときに加速させたいのですが、やり方がわかりません。
|
2
2
|
ボールにリジットボディと物理マテリアルをつけた後色々調べたんですが、検索の仕方が下手なのか何も出てきませんでした。
|
3
3
|
使用しているunityは2020の3.5f1です。
|
4
|
-
やり方を知っている方は教えていただけると幸いです。
|
4
|
+
やり方を知っている方は教えていただけると幸いです。
|
5
|
+
|
6
|
+
追記
|
7
|
+
|
8
|
+
現在のボールのコードは
|
9
|
+
using System.Collections;
|
10
|
+
using System.Collections.Generic;
|
11
|
+
using UnityEngine;
|
12
|
+
|
13
|
+
public class ball : MonoBehaviour
|
14
|
+
{
|
15
|
+
public float speed = 1.0f;
|
16
|
+
private Rigidbody myRigid;
|
17
|
+
|
18
|
+
// Start is called before the first frame update
|
19
|
+
void Start()
|
20
|
+
{
|
21
|
+
myRigid = this.GetComponent<Rigidbody>();
|
22
|
+
myRigid.AddForce((transform.forward + transform.right) * speed, ForceMode.VelocityChange);
|
23
|
+
}
|
24
|
+
|
25
|
+
// Update is called once per frame
|
26
|
+
void Update()
|
27
|
+
{
|
28
|
+
|
29
|
+
}
|
30
|
+
}
|
31
|
+
です。
|