実現したいこと
unityで3Ⅾのサッカーゲームを作っているのですが、ボールの半径≧キャラクターの位置関係になったらボールが跳ね返るというコードの書き方がわからないので教えていただきたいです。
発生している問題・分からないこと
void Update()以降の部分でエラーが発生してる状態です。
該当のソースコード
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class ballmove : MonoBehaviour { // Start is called before the first frame update private Rigidbody rb; void Start() { rb = GetComponent<Rigidbody>(); } // Update is called once per frame void Update() { float xDis = x2 - x1; float yDis = y2 - y1; float zDis = z2 - z1; double distance = Math.sqrt((xDis * xDis) + (yDis * yDis) + (zDis * zDis)); } }
試したこと・調べたこと
上記の詳細・結果
検索をかけてみましたがよくわかりませんでした。
補足
特になし
0 コメント