private void buttonShootBall_Click(object sender, EventArgs e) { Shape shape = new ShapeSphere(5); m_rigidBodies.Add(HelperRigidBody_c.CreateRigidBody(shape, Quaternion.Identity, new Vector3(0, 30, -100), 1.0f)); m_rigidBodies[m_rigidBodies.Count - 1].body.v += new Vector3(0, 0, 200); }
public bool HitTest(ShapeSphere other) { // 2つの球の半径の合計値 float sum_radius = radius + other.radius; // 2つの球の距離 float distance = Mathf.Sqrt(Mathf.Pow(other.transform.position.x - transform.position.x, 2) + Mathf.Pow(other.transform.position.y - transform.position.y, 2) + Mathf.Pow(other.transform.position.z - transform.position.z, 2)); // 2つの球の距離が半径の合計値よりも小さい場合、当たっている if (distance <= sum_radius) { return(true); } return(false); }
private void buttonSphere_Click(object sender, EventArgs e) { Shape shape = new ShapeSphere(5); ModifyRigidBody(shape); }