void Start() { IsKicking_Start = true; CollisionBall.IsClearance = false; IsKicking = false; switch (this.gameObject.name) { case "NPC1": case "NPC2": breakForce = 500; breakTorque = 100000000f; first_force = 170000; break; case "goalkeeper1": case "goalkeeper2": breakForce = 30000; breakTorque = 100000f; break; case "Player": breakForce = 45000f; breakTorque = 20000f; first_force = 100000f; break; } bt = GetComponent <BehaiorTree>(); gok = GetComponent <Goalkeeper_kick>(); kick_a = GetComponent <AudioSource>(); kick_b = ball.GetComponent <AudioSource>(); ball_rigid = ball.GetComponent <Rigidbody>(); if (mode == Mode.collision) { GetComponentInChildren <Collider>().isTrigger = false; } else if (mode == Mode.trigger) { GetComponentInChildren <Collider>().isTrigger = true; } who = null; w_p = null; have_ball_now = null; //SituationText.gameObject.SetActive(false); }
void JudgePlayer(Collider col) { if (this.gameObject.name == "NPC1" || this.gameObject.name == "NPC2") { //Debug.Log("SnapNPC"); have_ball_NPC = this.gameObject.GetComponent <BehaiorTree>(); } if (col.gameObject.tag == "SoccerBall") { if (fixedJoint == null) { if (this.gameObject.name == "NPC1" || this.gameObject.name == "NPC2") { if (bt.Who_ball() == null) { have_ball_man = this.gameObject.tag; have_ball_now = this.gameObject.name; } } if (this.gameObject.name == "Player" && w_p == null) { have_ball_man = this.gameObject.tag; have_ball_now = this.gameObject.name; } if (this.gameObject.tag == "goalkeeper") { if (this.gameObject.transform.position.z < 0) { have_ball_man = "Team1"; } if (this.gameObject.transform.position.z > 0) { have_ball_man = "Team2"; } CollisionBall.IsClearance = true; KeeperSource.PlayOneShot(KeeperSound[0]); StartCoroutine("freezetime"); }/*else{ * this.IsClearance = false; * }*/ Debug.Log(have_ball_man, this.gameObject); this.gameObject.AddComponent <FixedJoint>(); fixedJoint = this.gameObject.GetComponent <FixedJoint>(); ball.transform.position = ball_spot.transform.position; ball.gameObject.GetComponent <Rigidbody>().velocity = Vector3.zero; fixedJoint.connectedBody = col.gameObject.GetComponent <Rigidbody>(); if (have_ball_now == "Player") { SituationText.gameObject.SetActive(true); SituationText.text = "ボールスナッピング中!"; first_force = 100000f; kick_b.clip = kick_sound[1]; kick_b.Play(); } fixedJoint.breakForce = breakForce; fixedJoint.breakTorque = breakTorque; fixedJoint.enableCollision = true; isSnapping = true; Ball_force_con.joint_man = this.gameObject; w_p = this.GetComponent <Transform>().root; who = w_p.tag; GetComponent <Rigidbody>().Sleep(); //Debug.Log(w_p.tag); //Debug.Log(who); } } }