// Update is called once per frame void Update() { Lattach = ArmL.GetComponent <Attach> ().attach; Rattach = ArmR.GetComponent <Attach> ().attach; Debug.Log(Lattach); Debug.Log(Rattach); if (Lattach != null && Rattach != null) { Debug.Log(Lattach.gameObject.name); Debug.Log(Rattach.gameObject.name); if (Lattach.gameObject == Rattach.gameObject) { Debug.Log("Yes!!"); if (ArmL.GetComponent <ArmHasamuFlag> ().bHasamu&& ArmR.GetComponent <ArmHasamuFlag> ().bHasamu) { Lattach.gameObject.SetActive(false); } } else if (Lattach.gameObject.name == "ArmR" && Rattach.gameObject.name == "ArmL") { ArmRtoL = ArmL.GetComponent <GetArmHead> ().ArmHead - ArmR.GetComponent <GetArmHead> ().ArmHead; ArmRtoOL = Lattach.gameObject.GetComponent <GetArmHead> ().ArmHead - ArmR.GetComponent <GetArmHead> ().ArmHead; ArmRtoOR = Rattach.gameObject.GetComponent <GetArmHead> ().ArmHead - ArmR.GetComponent <GetArmHead> ().ArmHead; if (Vector3.Cross(ArmRtoL, ArmRtoOL).y <= 0 && Vector3.Cross(ArmRtoL, ArmRtoOR).y <= 0 && Vector3.Dot(ArmRtoL, ArmRtoOL) > 0 && Vector3.Dot(ArmRtoL, ArmRtoOR) > 0 ) { if (ArmL.GetComponent <ArmHasamuFlag> ().bHasamu&& ArmR.GetComponent <ArmHasamuFlag> ().bHasamu) { Lattach.gameObject.SetActive(false); Rattach.gameObject.SetActive(false); } } } } }
// Update is called once per frame void FixedUpdate() { if (Input.GetButtonDown("Fire2") && !CloseFlag && !OpenFlag) { CloseFlag = true; } if (CloseFlag) { ArmR.transform.RotateAround(transform.position, Vector3.up, -CloseSpeed * Time.deltaTime); ArmL.transform.RotateAround(transform.position, Vector3.up, CloseSpeed * Time.deltaTime); AlreadyRotation += CloseSpeed * Time.deltaTime; ArmR.GetComponent <ArmHasamuFlag>().bHasamu = true; ArmL.GetComponent <ArmHasamuFlag>().bHasamu = true; if (AlreadyRotation >= 30) { ArmR.transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0); ArmL.transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0); CloseFlag = false; OpenFlag = true; AlreadyRotation = 0; ArmR.GetComponent <ArmHasamuFlag>().bHasamu = false; ArmL.GetComponent <ArmHasamuFlag>().bHasamu = false; } } if (OpenFlag) { ArmR.transform.RotateAround(transform.position, Vector3.up, OpenSpeed * Time.deltaTime); ArmL.transform.RotateAround(transform.position, Vector3.up, -OpenSpeed * Time.deltaTime); AlreadyRotation += OpenSpeed * Time.deltaTime; if (AlreadyRotation >= 30) { ArmR.transform.eulerAngles = new Vector3(0, transform.eulerAngles.y + 30, 0); ArmL.transform.eulerAngles = new Vector3(0, transform.eulerAngles.y - 30, 0); OpenFlag = false; AlreadyRotation = 0; } } }
// Use this for initialization void Start() { Lattach = ArmL.GetComponent <Attach> ().attach; Rattach = ArmR.GetComponent <Attach> ().attach; }