// Update is called once per frame void Update() { if (Input.GetKeyUp(KeyCode.Tab)) { CType = (CtrlType)(((int)CType + 1) % 3); Debug.Log("当前控制:" + CType); } switch (CType) { case CtrlType.CtrlHead: _handler = _rope.ManualHead(true); break; case CtrlType.CtrlTail: _handler = _rope.ManualTail(true); break; case CtrlType.AutoFx: _handler = null; _rope.Auto(); break; } if (_handler != null) { if (Input.GetMouseButton(0)) { var ray = _cam.ScreenPointToRay(Input.mousePosition); RaycastHit info; if (Physics.Raycast(ray, out info, 1000, _floorLayerMask)) { _handler.position = info.point + new Vector3(0, RopeLength / 2, 0); } } } }
void Update() { if (Input.GetKeyUp(KeyCode.Tab)) { CType = (CtrlType)(((int)CType + 1) % 2); Debug.Log("当前控制:" + CType); } if (Input.GetKeyUp(KeyCode.Alpha1)) { if (_rope.GetHeadHang() == null) { _rope.HangHead(_obj1.GetComponent <Rigidbody>()); } else { _rope.HangHead(null); _rope.ManualHead(false); } } else if (Input.GetKeyUp(KeyCode.Alpha2)) { if (_rope.GetTailHang() == null) { _rope.HangTail(_obj2.GetComponent <Rigidbody>()); } else { _rope.HangTail(null); _rope.ManualTail(false); } } switch (CType) { case CtrlType.CtrlHead: _handler = _rope.GetHeadHang(); if (_handler == null) { _handler = _rope.GetHeadHandler().GetComponent <Rigidbody>(); _rope.ManualHead(true, _rope.GetTailHang() == null); } break; case CtrlType.CtrlTail: _handler = _rope.GetTailHang(); if (_handler == null) { _handler = _rope.GetTailHandler().GetComponent <Rigidbody>(); _rope.ManualTail(true, _rope.GetHeadHang() == null); } break; } if (_handler != null) { if (Input.GetMouseButton(0)) { var ray = _cam.ScreenPointToRay(Input.mousePosition); RaycastHit info; if (Physics.Raycast(ray, out info, 1000, _floorLayerMask)) { _handler.position = info.point + new Vector3(0, 0.011f / 2, 0); } } } }