void Update() { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit))//Rayが何かに当たった場合 (レイヤーがIgoneRaycastの物は当たらない) { hitObj = hit.collider.gameObject; chara = hitObj.GetComponent <Chara>(); int x = (int)hit.point.x;//マスの中央に来るようにする int z = (int)hit.point.z; if (hitObj.layer == 9) //マウスをcharaにあてた時 { if (mouseCursor) //charaのしたに表示する { charaPoint = true; //Vector3 mouseCursorP = new Vector3(hitObj.transform.position.x, hitObj.transform.position.y - 0.5f, hitObj.transform.position.z); Vector3 mouseCursorP = hitObj.transform.position; mouseCursorP.y += 0.01f; mouseCursor.transform.position = mouseCursorP; } if (Input.GetButtonDown("Fire1"))//test { charaButton.SetActive(true); Action(); pickUpScript.GetChara(hitObj); chara.CharaChoice(hitObj); MoveButtonFalse(); } } else { if (mouseCursor)//現在のマウスの位置 { charaPoint = false; Vector3 mouseCursorP = new Vector3(x, hit.point.y + 0.01f, z); mouseCursor.transform.position = mouseCursorP; } if (Input.GetButtonDown("Fire1") && moveButton)//clickしたとき移動する { Vector3 movePoint = new Vector3(x, hit.point.y, z); pickUpScript.CharaMove(movePoint); buttonMove.GetComponent <Button>().interactable = false; //human.transform.position = movePoint; //Debug.Log(hit.transform.position); } } } //Charaにマウスを当てた時に色を変える if (mouseCursorBlue && mouseCursorRed) { if (charaPoint) { mouseCursorBlue.SetActive(false); mouseCursorRed.SetActive(true); } else { mouseCursorBlue.SetActive(true); mouseCursorRed.SetActive(false); } } }