void SetLockTarget() { mTouches = Input.touches; if (Input.GetMouseButtonDown(0) || mTouches.Length > 0) { if (mTouches.Length > 0) { for (int i = 0; i < mTouches.Length; i++) { Touch touch = mTouches[i]; if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) { mIsTouched = true; mTouchPos = touch.position; } } } else { mIsTouched = true; mTouchPos = Input.mousePosition; } } if (mIsTouched) { mIsTouched = false; Ray ray = Camera.main.ScreenPointToRay(mTouchPos); RaycastHit hit; if (Physics.Raycast(ray, out hit, GameLibrary.GetMaxRayDistance(), GameLibrary.GetAllLayer())) { CharacterState hitCS = hit.transform.GetComponent <CharacterState>(); if (hitCS != null && hitCS.groupIndex != playerGroupIndex) { lockedTarget = hitCS; } } } }